markevans/dragonfly — Issue #138: Assets:precompile fails on Rails 3.1.1 on Heroku due to missing S3_KEY during initialization
Author: plindelauf
Created: 2011-10-17 12:06:40+00:00
State: open

Whenever a `rake assets:precompile` is run during deployment to Heroku Cedar with Rails 3.1.1, it fails. This is the trace I'm getting:

/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.4/lib/rack/backports/uri/common_192.rb:53: warning: already initialized constant WFKV_
/Users/pascal/.rvm/rubies/ruby-1.9.2-p290/bin/ruby /Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rack-1.3.4/lib/rack/backports/uri/common_192.rb:53: warning: already initialized constant WFKV_
WARNING: Nokogiri was built against LibXML version 2.7.8, but has dynamically loaded 2.7.3
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
rake aborted!
ENV variable 'S3_KEY' needs to be set - use
heroku config:add S3_KEY=XXXXXXXXX
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/dragonfly-0.9.8/lib/dragonfly/config/heroku.rb:11:in `block (2 levels) in apply_configuration'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/dragonfly-0.9.8/lib/dragonfly/configurable.rb:35:in `configure'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/dragonfly-0.9.8/lib/dragonfly/config/heroku.rb:9:in `block in apply_configuration'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/dragonfly-0.9.8/lib/dragonfly/configurable.rb:35:in `configure'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/dragonfly-0.9.8/lib/dragonfly/config/heroku.rb:7:in `apply_configuration'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/dragonfly-0.9.8/lib/dragonfly/configurable.rb:41:in `configure_with'
/Users/pascal/Projecten/RoR/bizplay/config/initializers/dragonfly.rb:7:in `'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.1.1.rc3/lib/active_support/dependencies.rb:234:in `load'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.1.1.rc3/lib/active_support/dependencies.rb:234:in `block in load'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.1.1.rc3/lib/active_support/dependencies.rb:225:in `load_dependency'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.1.1.rc3/lib/active_support/dependencies.rb:234:in `load'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.1.rc3/lib/rails/engine.rb:556:in `block (2 levels) in '
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.1.rc3/lib/rails/engine.rb:555:in `each'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.1.rc3/lib/rails/engine.rb:555:in `block in '
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.1.rc3/lib/rails/initializable.rb:30:in `instance_exec'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.1.rc3/lib/rails/initializable.rb:30:in `run'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.1.rc3/lib/rails/initializable.rb:55:in `block in run_initializers'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.1.rc3/lib/rails/initializable.rb:54:in `each'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.1.rc3/lib/rails/initializable.rb:54:in `run_initializers'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.1.rc3/lib/rails/application.rb:96:in `initialize!'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.1.rc3/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/pascal/Projecten/RoR/bizplay/config/environment.rb:5:in `'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.1.1.rc3/lib/active_support/dependencies.rb:240:in `require'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.1.1.rc3/lib/active_support/dependencies.rb:240:in `block in require'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.1.1.rc3/lib/active_support/dependencies.rb:223:in `block in load_dependency'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.1.1.rc3/lib/active_support/dependencies.rb:640:in `new_constants_in'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.1.1.rc3/lib/active_support/dependencies.rb:223:in `load_dependency'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.1.1.rc3/lib/active_support/dependencies.rb:240:in `require'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.1.rc3/lib/rails/application.rb:83:in `require_environment!'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.1.1.rc3/lib/rails/application.rb:193:in `block (2 levels) in initialize_tasks'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task.rb:205:in `block in execute'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/pascal/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/actionpack-3.1.1.rc3/lib/sprockets/assets.rake:89:in `block (2 levels) in '
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task.rb:205:in `block in execute'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/pascal/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task.rb:174:in `each'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/Users/pascal/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/gems/actionpack-3.1.1.rc3/lib/sprockets/assets.rake:56:in `block (3 levels) in '
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task.rb:205:in `block in execute'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/pascal/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/application.rb:112:in `invoke_task'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/application.rb:90:in `block (2 levels) in top_level'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/application.rb:90:in `each'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/application.rb:90:in `block in top_level'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/application.rb:84:in `top_level'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/application.rb:62:in `block in run'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@global/gems/rake-0.9.2/bin/rake:32:in `'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/bin/rake:19:in `load'
/Users/pascal/.rvm/gems/ruby-1.9.2-p290@rails31/bin/rake:19:in `

'
Tasks: TOP => environment
rake aborted!
Command failed with status (1): [/Users/pascal/.rvm/rubies/ruby-1.9.2-p290/...]

Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

Note that the S3_KEY *is* set in the production environment, but as the [Heroku documentation](http://devcenter.heroku.com/articles/rails31_heroku_cedar) says:
> The app’s config vars are not available in the environment
> during the slug compilation process. Because the app must
> be loaded to run the assets:precompile task, any initialization
> code that requires existence of config vars should gracefully
> handle the nil case.

I'm guessing Dragonfly is missing this "graceful handling of the nil case". I'm using Dragonfly 0.9.8.