简体   繁体   中英

Why does Rails give “`require': cannot load such file — singleton” only on production server?

I'm trying to convert a Rails 4.0 project from PostgreSQL to MySQL.

I have everything working in my local Vagrant VM, but after I do cap deploy , this is what I see in the logs on the production server:

I, [2015-03-25T15:39:12.558662 #28566]  INFO -- : Refreshing Gem list
[snip]/shared/bundle/ruby/2.2.0/gems/activesupport-4.0.13/lib/active_support/deprecation.rb:1:in `require': cannot load such file -- singleton (LoadError)
        from [snip]/shared/bundle/ruby/2.2.0/gems/activesupport-4.0.13/lib/active_support/deprecation.rb:1:in `<top (required)>'
        from [snip]/shared/bundle/ruby/2.2.0/gems/railties-4.0.13/lib/rails/configuration.rb:1:in `require'
        from [snip]/shared/bundle/ruby/2.2.0/gems/railties-4.0.13/lib/rails/configuration.rb:1:in `<top (required)>'
        from [snip]/shared/bundle/ruby/2.2.0/gems/railties-4.0.13/lib/rails/railtie.rb:2:in `require'
        from [snip]/shared/bundle/ruby/2.2.0/gems/railties-4.0.13/lib/rails/railtie.rb:2:in `<top (required)>'
        from [snip]/shared/bundle/ruby/2.2.0/gems/railties-4.0.13/lib/rails/engine.rb:1:in `require'
        from [snip]/shared/bundle/ruby/2.2.0/gems/railties-4.0.13/lib/rails/engine.rb:1:in `<top (required)>'
        from [snip]/shared/bundle/ruby/2.2.0/gems/railties-4.0.13/lib/rails/application.rb:4:in `require'
        from [snip]/shared/bundle/ruby/2.2.0/gems/railties-4.0.13/lib/rails/application.rb:4:in `<top (required)>'
        from [snip]/shared/bundle/ruby/2.2.0/gems/railties-4.0.13/lib/rails.rb:9:in `require'
        from [snip]/shared/bundle/ruby/2.2.0/gems/railties-4.0.13/lib/rails.rb:9:in `<top (required)>'
        from [snip]/shared/bundle/ruby/2.2.0/gems/railties-4.0.13/lib/rails/all.rb:1:in `require'
        from [snip]/shared/bundle/ruby/2.2.0/gems/railties-4.0.13/lib/rails/all.rb:1:in `<top (required)>'
        from [snip]/releases/20150325221423/config/application.rb:3:in `require'
        from [snip]/releases/20150325221423/config/application.rb:3:in `<top (required)>'
        from [snip]/releases/20150325221423/config/environment.rb:2:in `require'
        from [snip]/releases/20150325221423/config/environment.rb:2:in `<top (required)>'
        from config.ru:4:in `require'
        from config.ru:4:in `block in <main>'
        from [snip]/shared/bundle/ruby/2.2.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
        from [snip]/shared/bundle/ruby/2.2.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
        from config.ru:1:in `new'
        from config.ru:1:in `<main>'
        from [snip]/shared/bundle/ruby/2.2.0/gems/unicorn-4.8.3/lib/unicorn.rb:48:in `eval'
        from [snip]/shared/bundle/ruby/2.2.0/gems/unicorn-4.8.3/lib/unicorn.rb:48:in `block in builder'
        from [snip]/shared/bundle/ruby/2.2.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:764:in `call'
        from [snip]/shared/bundle/ruby/2.2.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:764:in `build_app!'
        from [snip]/shared/bundle/ruby/2.2.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:628:in `init_worker_process'
        from [snip]/shared/bundle/ruby/2.2.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:651:in `worker_loop'
        from [snip]/shared/bundle/ruby/2.2.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:525:in `spawn_missing_workers'
        from [snip]/shared/bundle/ruby/2.2.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:536:in `maintain_worker_count'
        from [snip]/shared/bundle/ruby/2.2.0/gems/unicorn-4.8.3/lib/unicorn/http_server.rb:294:in `join'
        from [snip]/shared/bundle/ruby/2.2.0/gems/unicorn-4.8.3/bin/unicorn:126:in `<top (required)>'
        from [snip]/shared/bundle/ruby/2.2.0/bin/unicorn:23:in `load'
        from [snip]/shared/bundle/ruby/2.2.0/bin/unicorn:23:in `<main>'
E, [2015-03-25T15:39:12.723362 #1450] ERROR -- : reaped #<Process::Status: pid 28563 exit 1> worker=0

But my understanding is that singleton is a Ruby feature, not some third-party library that I might be missing. Is that correct? What is the problem here?

Edit: I am in the process of adding Chef to this project. I have set up a second Vagrant VM to test the production config on before I apply it to the actual production server. I have configured this VM to match the production server, as close as I can tell, but the VM works fine.

I finished adding Chef to the project and now use it to configure the production server. Around the same time I also upgraded to Rails 4.2.

I'm no longer getting this error, so it is likely one of those two things that fixed the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM