2
我完成了從Rails 3.0.10升級到3.1.1之後的下一個these instructions並且能夠成功啓動一個帶有rails s
的rails服務器,但是一旦我使用development
以外的RAILS_ENV
變量,就會發生錯誤。「沒有這樣的文件加載 - importenv」在Rails 3.0.10之後升級到3.1.1升級時運行「rails c production」
rails c
的作品,但rails c production
,rails c test
,或者任何自定義環境 的結果是 「沒有這樣的文件來加載 - importenv(LoadError)」 的錯誤。
這裏的堆棧跟蹤:
from /gems/activesupport-3.1.1/lib/active_support/dependencies.rb:306:in `rescue in depend_on': No such file to load -- importenv (LoadError)
from /gems/activesupport-3.1.1/lib/active_support/dependencies.rb:301:in `depend_on'
from /gems/activesupport-3.1.1/lib/active_support/dependencies.rb:214:in `require_dependency'
from /gems/railties-3.1.1/lib/rails/engine.rb:417:in `block (2 levels) in eager_load!'
from /gems/railties-3.1.1/lib/rails/engine.rb:416:in `each'
from /gems/railties-3.1.1/lib/rails/engine.rb:416:in `block in eager_load!'
from /gems/railties-3.1.1/lib/rails/engine.rb:414:in `each'
from /gems/railties-3.1.1/lib/rails/engine.rb:414:in `eager_load!'
from /gems/railties-3.1.1/lib/rails/application/finisher.rb:51:in `block in <module:Finisher>'
from /gems/railties-3.1.1/lib/rails/initializable.rb:30:in `instance_exec'
from /gems/railties-3.1.1/lib/rails/initializable.rb:30:in `run'
from /gems/railties-3.1.1/lib/rails/initializable.rb:55:in `block in run_initializers'
from /gems/railties-3.1.1/lib/rails/initializable.rb:54:in `each'
from /gems/railties-3.1.1/lib/rails/initializable.rb:54:in `run_initializers'
from /gems/railties-3.1.1/lib/rails/application.rb:96:in `initialize!'
from /gems/railties-3.1.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /config/environment.rb:5:in `<top (required)>'
from /ges/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
from /gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `block in require'
from /gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `block in load_dependency'
from /gems/activesupport-3.1.1/lib/active_support/dependencies.rb:640:in `new_constants_in'
from /gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `load_dependency'
from /gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
from /gems/railties-3.1.1/lib/rails/application.rb:83:in `require_environment!'
from /gems/railties-3.1.1/lib/rails/commands.rb:39:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
如果您在開發環境中運行「Rails.application.config.eager_load_paths」,會返回什麼結果?看起來'eager_load!'只有在'config.cache_classes'設置爲true並且Rails沒有從rake任務加載時才被調用,因此值得嘗試查看'RAILS_ENV =生產rake統計信息'是否可以縮小解決這個問題。 – Garrett 2012-01-11 08:55:13