uninitialized constant Devise (NameError)

2019-06-08 11:29发布

问题:

I have a problem when deploying my app in production... My Gemfile contains gem 'devise' and everything work fine in development...

Here is my unicorn_stderr.log file where [XXXXXX] is my rails app folder.

I, [2013-02-05T13:49:10.820924 #18780]  INFO -- : Refreshing Gem list
E, [2013-02-05T13:49:14.488684 #18777] ERROR -- : uninitialized constant Devise (NameError)
[XXXXXX]/releases/20130205012052/config/initializers/devise.rb:3:in `<top (required)>'
[XXXXXX]/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:588:in `block (2 levels) in <class:Engine>'
[XXXXXX]/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:587:in `each'
[XXXXXX]/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:587:in `block in <class:Engine>'
[XXXXXX]/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `instance_exec'
[XXXXXX]/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `run'
[XXXXXX]/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:55:in `block in run_initializers'
[XXXXXX]/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `each'
[XXXXXX]/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `run_initializers'
[XXXXXX]/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/application.rb:136:in `initialize!'
[XXXXXX]/shared/bundle/ruby/1.9.1/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in `method_missing'
[XXXXXX]/releases/20130205012052/config/environment.rb:5:in `<top (required)>'
config.ru:4:in `require'
config.ru:4:in `block in <main>'
[XXXXXX]/shared/bundle/ruby/1.9.1/gems/rack-1.4.4/lib/rack/builder.rb:51:in `instance_eval'
[XXXXXX]/shared/bundle/ruby/1.9.1/gems/rack-1.4.4/lib/rack/builder.rb:51:in `initialize'
config.ru:1:in `new'
config.ru:1:in `<main>'
[XXXXXX]/shared/bundle/ruby/1.9.1/gems/unicorn-4.5.0/lib/unicorn.rb:44:in `eval'
[XXXXXX]/shared/bundle/ruby/1.9.1/gems/unicorn-4.5.0/lib/unicorn.rb:44:in `block in builder'
[XXXXXX]/shared/bundle/ruby/1.9.1/gems/unicorn-4.5.0/lib/unicorn/http_server.rb:718:in `call'
[XXXXXX]/shared/bundle/ruby/1.9.1/gems/unicorn-4.5.0/lib/unicorn/http_server.rb:718:in `build_app!'
[XXXXXX]/shared/bundle/ruby/1.9.1/gems/unicorn-4.5.0/lib/unicorn/http_server.rb:591:in `init_worker_process'
[XXXXXX]/shared/bundle/ruby/1.9.1/gems/unicorn-4.5.0/lib/unicorn/http_server.rb:611:in `worker_loop'
[XXXXXX]/shared/bundle/ruby/1.9.1/gems/unicorn-4.5.0/lib/unicorn/http_server.rb:500:in `spawn_missing_workers'
[XXXXXX]/shared/bundle/ruby/1.9.1/gems/unicorn-4.5.0/lib/unicorn/http_server.rb:511:in `maintain_worker_count'
[XXXXXX]/shared/bundle/ruby/1.9.1/gems/unicorn-4.5.0/lib/unicorn/http_server.rb:277:in `join'
[XXXXXX]/shared/bundle/ruby/1.9.1/gems/unicorn-4.5.0/bin/unicorn:121:in `<top (required)>'
[XXXXXX]/shared/bundle/ruby/1.9.1/bin/unicorn:23:in `load'
[XXXXXX]/shared/bundle/ruby/1.9.1/bin/unicorn:23:in `<main>'
E, [2013-02-05T13:49:14.502380 #17308] ERROR -- : reaped #<Process::Status: pid 18777 exit 1> worker=1
I, [2013-02-05T13:49:14.502544 #17308]  INFO -- : worker=1 spawning...
I, [2013-02-05T13:49:14.512618 #18783]  INFO -- : worker=1 spawned pid=18783
I, [2013-02-05T13:49:14.512882 #18783]  INFO -- : Refreshing Gem list

I don't understand the problem...I googled this but i found nothing helping me, I hope somebody can help me !

回答1:

I fixed it... My script/rails and config/unicorn_init.sh wasn't executable so a simple chmod u+x on these files solved my problem. It wasn't a problem with devise !



回答2:

Have the same issue today on production server after I deploy new version with Devise. I read a lot of topics, checked all configuration files, everything was OK but unicorn wrote the next in log file:

ERROR -- : uninitialized constant Devise (NameError)

My solution was: to STOP and to START unicorn daemon. RESTART doesn't help. As a flag of success - you need to check /tmp/pids/ folder. When you stop the process, this folder becomes empty.