开发者

"config.cache_classes = true" No such file to load -- /path-to-app/app/config/environment (LoadError)

开发者 https://www.devze.com 2023-03-29 03:59 出处:网络
The application won\'t start in the production mode with config.cache_classes set to true. It gives the following error with the stacktrace:

The application won't start in the production mode with config.cache_classes set to true. It gives the following error with the stacktrace:

    $ bundle exec rails s -e production
 /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:304:in `rescue in depend_on': No such file to load -- /path-to-app/app/config/environment (LoadError)
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:299:in `depend_on'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:216:in `require_dependency'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/engine.rb:138:in `block (2 levels) in eager_load!'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/engine.rb:137:in `each'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/engine.rb:137:in `block in eager_load!'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/engine.rb:135:in `each开发者_运维技巧'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/engine.rb:135:in `eager_load!'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/application.rb:108:in `eager_load!'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/application/finisher.rb:41:in `block in <module:Finisher>'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/initializable.rb:25:in `instance_exec'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/initializable.rb:25:in `run'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/initializable.rb:50:in `block in run_initializers'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/initializable.rb:49:in `each'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/initializable.rb:49:in `run_initializers'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/application.rb:134:in `initialize!'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/application.rb:77:in `method_missing'
    from /path-to-app/config/environment.rb:5:in `<top (required)>'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `block in require'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in `block in load_dependency'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:596:in `new_constants_in'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:225:in `load_dependency'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.0.7/lib/active_support/dependencies.rb:239:in `require'
    from /path-to-app/config.ru:3:in `block in <main>'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.2.3/lib/rack/builder.rb:46:in `instance_eval'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.2.3/lib/rack/builder.rb:46:in `initialize'
    from /path-to-app/config.ru:1:in `new'
    from /path-to-app/config.ru:1:in `<main>'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.2.3/lib/rack/builder.rb:35:in `eval'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.2.3/lib/rack/builder.rb:35:in `parse_file'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.2.3/lib/rack/server.rb:162:in `app'     
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.2.3/lib/rack/server.rb:253:in `wrapped_app'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.2.3/lib/rack/server.rb:204:in `start'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/commands/server.rb:65:in `start'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/commands.rb:30:in `block in <top (required)>'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/commands.rb:27:in `tap'
    from /home/vipin/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.7/lib/rails/commands.rb:27:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Strangely it works fine with caching turned-off. My production.rb file look like

App::Application.configure do

    config.cache_classes = true  
    config.consider_all_requests_local       = false
    config.action_controller.perform_caching = true 
    config.action_dispatch.x_sendfile_header = "X-Sendfile"
    config.action_mailer.delivery_method = :sendmail
    config.action_mailer.perform_deliveries = true
    config.action_mailer.raise_delivery_errors = true
    config.serve_static_assets = false
    config.i18n.fallbacks = true
    config.active_support.deprecation = :notify
    config.action_dispatch.best_standards_support = :builtin
end

I am using the following gems:

source 'http://rubygems.org'

gem 'rails', '3.0.7'

gem 'mysql2', '0.2.1'

gem 'carrierwave'

gem 'rmagick'

gem "capistrano-ext"

gem 'rake', '0.8.7'

group :development do

  gem 'rspec-rails', '2.1.0'

  gem 'ruby-debug19'

  gem 'wirble'

end

group :test do

  gem 'ruby-debug19'

  gem 'rspec', '2.1.0'

  gem 'webrat', '0.7.1'

  gem 'factory_girl_rails', '1.0'

end
gem 'thinking-sphinx', '2.0.3'

I really appreciate any help


I knew, I was doing something stupid(though it wasn't all me, the same old designer story. I should have checked git commits). I had spec folder in the app directory and in the project directory too. But I am still confused why'd it work with

config.cache_classes = false

in the production.rb.

0

精彩评论

暂无评论...
验证码 换一张
取 消