Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Assets:precompile fails on Rails 3.1.1 on Heroku due to missing S3_KEY during initialization #138

Closed
plindelauf opened this Issue Oct 17, 2011 · 4 comments

Comments

Projects
None yet
3 participants

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 `<top (required)>'
/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 <class:Engine>'
/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 <class:Engine>'
/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 `<top (required)>'
/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 <top (required)>'
/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 <top (required)>'
/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 `<top (required)>'
/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 `<main>'
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 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.

I found out that setting config.assets.initialize_on_precompile = false in application.rb solves the problem!

@plindelauf plindelauf closed this Oct 17, 2011

tleach commented Nov 24, 2011

I'm having the same problem. Unfortunately setting config.assets.initialize_on_precompile = false in application.rb doesn't seem to fix it for me and it still complains about the missing S3_KEY environment variable.

tleach commented Nov 27, 2011

Actually, scratch that. I was on Rails 3.1.0 and upgrading to 3.1.1 fixed the problem (along with a boat load of others).

I fixed this by running: rake assets:precompile RAILS_ENV=development

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment