Question

I completed the upgrade from Rails 3.0.10 to 3.1.1 following these instructions and was able to successfully start a rails server with rails s, but ran into an error as soon as I used RAILS_ENV variables other than development.

rails c works, but rails c production, rails c test, or any custom environment results in a "No such file to load -- importenv (LoadError)" error.

Here's the stack trace:

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>'
Was it helpful?

Solution

Turns out there were *.rb files in a subdirectory of app/assets/javascripts/ and they were being found and loaded (the ruby files are part of a js project that reads ruby files).

Moving the offending files to vendor/assets/javascripts/ fixed the issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top