2

我加入資產管道到我的Heroku託管的Rails 3.1應用程序,當我運行資產預編譯錯誤:未初始化的常量蒙戈::登錄

RAILS_ENV=production bundle exec rake assets:precompile 

通過本地的Heroku here的建議,它打破了錯誤:

rake aborted! uninitialized constant Mongo::Logging

Tasks: TOP => environment

我試過幾個步驟,其中包括建議的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

你可以發佈更長的堆棧跟蹤?你有沒有在你的Gemfile中指定gem'mongo'? – 2012-04-03 20:26:41

+0

謝謝。是的,我有mongo寶石,並添加了堆棧跟蹤。引起它的行是這似乎從rpm gem rpm_contrib-2.1.8/lib/rpm_contrib/instrumentation/mongo.rb:14其中:: Mongo :: Logging.class_eval在DependencyDetection下執行。我如何過來呢? – 2012-04-04 06:15:59

回答

1

這是因爲你用最後rpm_contrib寶石,而不是最後的mongo-ruby-driver寶石。

所以你需要在new_relic rpm上去激活MongoDB工具。或者你可以降級版本或rpm_contrib,或升級到Mongo的紅寶石驅動程序> = 1.6

+0

工作!非常感謝你! – 2012-04-04 10:00:14