我正在为我的Heroku托管的Rails 3.1应用程序添加Asset Pipeline,当我运行
时RAILS_ENV=production bundle exec rake assets:precompile
根据Heroku here的建议在本地,它会出错:
耙子流产了!未初始化的常量Mongo :: Logging任务:TOP =>环境
我尝试了几个步骤,包括建议的Heroku
config.assets.initialize_on_precompile = false
当我将它推向生产时,应用程序崩溃,同样的错误。据我所知,它正在尝试在编译期间使用尚未在此阶段初始化的对象。什么是正确的方法?
[更新]堆栈跟踪
ROOT /Users/bashar/rails-projects/myapp
** 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!
uninitialized constant Mongo::Logging
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rpm_contrib-2.1.8/lib/rpm_contrib/instrumentation/mongo.rb:14:in `block (2 levels) in <top (required)>'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/newrelic_rpm-3.3.3/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb:49:in `call'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/newrelic_rpm-3.3.3/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb:49:in `block in execute'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/newrelic_rpm-3.3.3/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb:48:in `each'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/newrelic_rpm-3.3.3/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb:48:in `execute'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/newrelic_rpm-3.3.3/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb:15:in `block in detect!'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/newrelic_rpm-3.3.3/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb:13:in `each'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/newrelic_rpm-3.3.3/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb:13:in `detect!'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/newrelic_rpm-3.3.3/lib/new_relic/control/instrumentation.rb:94:in `_install_instrumentation'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/newrelic_rpm-3.3.3/lib/new_relic/control/instrumentation.rb:53:in `install_instrumentation'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/newrelic_rpm-3.3.3/lib/new_relic/control/instance_methods.rb:77:in `init_plugin'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/newrelic_rpm-3.3.3/lib/newrelic_rpm.rb:36:in `block in <class:Railtie>'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/initializable.rb:30:in `instance_exec'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/initializable.rb:30:in `run'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/initializable.rb:55:in `block in run_initializers'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/initializable.rb:54:in `each'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/initializable.rb:54:in `run_initializers'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/application.rb:96:in `initialize!'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/bashar/rails-projects/myapp/config/environment.rb:5:in `<top (required)>'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/application.rb:83:in `require_environment!'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/application.rb:193:in `block (2 levels) in initialize_tasks'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/actionpack-3.1.3/lib/sprockets/assets.rake:89:in `block (2 levels) in <top (required)>'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/actionpack-3.1.3/lib/sprockets/assets.rake:56:in `block (3 levels) in <top (required)>'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/bashar/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `load'
/Users/bashar/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `<main>'
Tasks: TOP => environment
rake aborted!
Command failed with status (1): [/Users/bashar/.rvm/rubies/ruby-1.9.2-p29...]
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/file_utils.rb:53:in `block in create_shell_runner'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/file_utils.rb:45:in `call'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/file_utils.rb:45:in `sh'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `sh'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/file_utils.rb:80:in `ruby'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `ruby'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/actionpack-3.1.3/lib/sprockets/assets.rake:9:in `ruby_rake_task'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/actionpack-3.1.3/lib/sprockets/assets.rake:17:in `invoke_or_reboot_rake_task'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/actionpack-3.1.3/lib/sprockets/assets.rake:25:in `block (2 levels) in <top (required)>'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/bashar/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/bashar/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `load'
/Users/bashar/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `<main>'
Tasks: TOP => assets:precompile
由于
答案 0 :(得分:1)
这是因为你使用的是最后一个rpm_contrib
宝石,而不是最后一个mongo-ruby-driver
宝石。
因此,您需要在new_relic rpm上停用MongoDB检测。或者您可以降级版本或rpm_contrib,或升级到Mongo ruby驱动程序&gt; = 1.6