Reputation: 43401
I'm using the asset_sync gem with a Heroku deployment (Rails 3.2.3). Precompilation works nicely locally (pushing assets up to my AWS bucket without issues), but when I push to Heroku, it hangs during asset precompilation.
Preparing app for Rails asset pipeline
Running: rake assets:precompile
AssetSync: using default configuration from built-in initializer
Then eventually it times out with no explaination:
/app/slug-compiler/lib/utils.rb:66:in `block (2 levels) in spawn': command='/app/slug-compiler/lib/../../tmp/buildpacks/ruby/bin/compile /tmp/build_33de6far26atq /app/tmp/repo.git/.cache' exit_status=0 out='' at=timeout elapsed=900.1074194908142 (Utils::TimeoutError)
from /app/slug-compiler/lib/utils.rb:52:in `loop'
from /app/slug-compiler/lib/utils.rb:52:in `block in spawn'
from /app/slug-compiler/lib/utils.rb:47:in `popen'
from /app/slug-compiler/lib/utils.rb:47:in `spawn'
from /app/slug-compiler/lib/buildpack.rb:38:in `block in compile'
from /app/slug-compiler/lib/buildpack.rb:36:in `fork'
from /app/slug-compiler/lib/buildpack.rb:36:in `compile'
from /app/slug-compiler/lib/slug.rb:487:in `block in run_buildpack'
from /app/slug-compiler/lib/utils.rb:121:in `log'
from /app/slug-compiler/lib/slug.rb:743:in `log'
from /app/slug-compiler/lib/slug.rb:486:in `run_buildpack'
from /app/slug-compiler/lib/slug.rb:116:in `block (2 levels) in compile'
from /app/slug-compiler/lib/utils.rb:102:in `block in timeout'
from /usr/local/lib/ruby/1.9.1/timeout.rb:58:in `timeout'
from /app/slug-compiler/lib/utils.rb:102:in `rescue in timeout'
from /app/slug-compiler/lib/utils.rb:97:in `timeout'
from /app/slug-compiler/lib/slug.rb:104:in `block in compile'
from /app/slug-compiler/lib/utils.rb:121:in `log'
from /app/slug-compiler/lib/slug.rb:743:in `log'
from /app/slug-compiler/lib/slug.rb:103:in `compile'
from /app/slug-compiler/bin/slugc:85:in `block in <main>'
from /app/slug-compiler/lib/slug.rb:495:in `block in lock'
from /app/slug-compiler/lib/repo_lock.rb:44:in `call'
from /app/slug-compiler/lib/repo_lock.rb:44:in `run'
from /app/slug-compiler/lib/slug.rb:495:in `lock'
from /app/slug-compiler/bin/slugc:66:in `<main>'
! Heroku push rejected, failed to compile Ruby/rails app
$ heroku config
shows that I have set the following ENVs which I have checked again and again. I know they are the correct values because they work when I precompile locally:
AWS_ACCESS_KEY_ID: XXXX
AWS_SECRET_ACCESS_KEY: XXXX
FOG_DIRECTORY: XXXX
FOG_PROVIDER: AWS
FOG_REGION: eu-west-1
I do not have my public/assets folder checked in, and I have the following setup in my production.rb:
# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = false
# Compress JavaScripts and CSS
config.assets.compress = true
# Don't fallback to assets pipeline if a precompiled asset is missed (This would involve live compilation and a big performance issue)
config.assets.compile = false
# Generate digests for assets URLs (Fingerprinting)
config.assets.digest = true
# (Heroku requires that this be false)
config.assets.initialize_on_precompile = false
# AWS Bucket
config.action_controller.asset_host = "http://#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com"
I have set the following on Heroku as mentioned in asset_sync's README:
$heroku labs:enable user-env-compile -a myapp
What might be causing these issues and/or how can I debug them further. I can't see a way of getting more information about why the precompilation is hanging on Heroku.
Upvotes: 2
Views: 948
Reputation: 43401
Turns out it was a problem in the Sass compiler. It was choking on something without throwing any kind of error. I managed to get a bit more information using the steps outlined here, by waiting until it was hung, then quitting the process. That gave me a stack trace back to the sass parser. Think it was some kind of circular dependency.
Upvotes: 1