Rails 3 Devise 或 Authlogic - 生产环境神秘地看不到 Gem?适用于开发
这个问题可能很容易解决,但不知何故我找不到解决方案。
Authlogic 和 Devise 都会发生这种情况。我已经把头撞在墙上太久了,以至于我实际上撕掉了 Authlogic 并重新启动了 Devise——但遇到了同样的问题。
在开发上一切都很好。
然而,当我进入生产环境时,每当我尝试 rake db:seed 或运行控制台时,我都会收到此消息。这也显示我重新启动服务器和我的 gemfile。
为什么生产看不到宝石?似乎能够看到其他宝石就好了。
你看到的 gem 是 Github 版本——这是一个推荐的修复方案,但对我来说不起作用。我使用默认版本和强制使用特定版本得到了相同的结果。
Authlogic 和 Devise 都存在相同问题的事实似乎表明我的生产配置存在一些问题?除了 Gemfile 之外还能是什么?
开发 - Rails 3.0.4、1.9.2p136 Prod - Rails 3.0.4、1.9.2p0
最后的手段是升级 Ruby,以便它们匹配,但我怀疑这就是问题所在,而且由于某些原因,这将是大量工作,我不会在这里讨论。
ops@lightserve2:/home/proj/current$ touch tmp/restart.txt
ops@lightserve2:/home/proj/current$ r c
/home/darkserve/releases/20110217175218/config/initializers/devise.rb:3:in `<top (required)>': uninitialized constant Devise (NameError)
from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/engine.rb:201:in `block (2 levels) in <class:Engine>'
from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/engine.rb:200:in `each'
from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/engine.rb:200:in `block in <class:Engine>'
from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/initializable.rb:25:in `instance_exec'
from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/initializable.rb:25:in `run'
from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/initializable.rb:50:in `block in run_initializers'
from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/initializable.rb:49:in `each'
from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/initializable.rb:49:in `run_initializers'
from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/application.rb:134:in `initialize!'
from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/application.rb:77:in `method_missing'
from /home/darkserve/releases/20110217175218/config/environment.rb:5:in `<top (required)>'
from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/application.rb:103:in `require_environment!'
from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/commands.rb:22:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
ops@lightserve2:/home/darkserve/current$ cat Gemfile.lock
GIT
remote: http://github.com/JonasNielsen/nifty-generators.git
revision: 432d05d55b55e030d6c16b9d71b392181bca45f8
specs:
nifty-generators (0.4.3)
GIT
remote: http://github.com/plataformatec/devise.git
revision: 7113beac81a12da06be2d08bbfaec79017e9fdbf
specs:
devise (1.2.rc)
bcrypt-ruby (~> 2.1.2)
orm_adapter (~> 0.0.3)
warden (~> 1.0.3)
GEM
remote: http://rubygems.org/
specs:
aaronh-chronic (0.3.9)
abstract (1.0.0)
actionmailer (3.0.4)
actionpack (= 3.0.4)
mail (~> 2.2.15)
actionpack (3.0.4)
activemodel (= 3.0.4)
activesupport (= 3.0.4)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4)
rack (~> 1.2.1)
rack-mount (~> 0.6.13)
rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
activemodel (3.0.4)
activesupport (= 3.0.4)
builder (~> 2.1.2)
i18n (~> 0.4)
activerecord (3.0.4)
activemodel (= 3.0.4)
activesupport (= 3.0.4)
arel (~> 2.0.2)
tzinfo (~> 0.3.23)
activeresource (3.0.4)
activemodel (= 3.0.4)
activesupport (= 3.0.4)
activesupport (3.0.4)
arel (2.0.8)
bcrypt-ruby (2.1.4)
builder (2.1.2)
capistrano (2.5.19)
highline
net-scp (>= 1.0.0)
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.0.0)
crack (0.1.8)
erubis (2.6.6)
abstract (>= 1.0.0)
foreigner (0.9.1)
haml (3.0.25)
haml-rails (0.3.4)
actionpack (~> 3.0)
activesupport (~> 3.0)
haml (~> 3.0)
railties (~> 3.0)
highline (1.6.1)
hpricot (0.8.3)
httparty (0.7.4)
crack (= 0.1.8)
i18n (0.5.0)
json (1.5.1)
mail (2.2.15)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mash (0.1.1)
mime-types (1.16)
mocha (0.9.12)
mysql2 (0.2.6)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-sftp (2.0.5)
net-ssh (>= 2.0.9)
net-ssh (2.1.0)
net-ssh-gateway (1.0.1)
net-ssh (>= 1.99.1)
nokogiri (1.4.4)
oauth (0.4.4)
orm_adapter (0.0.4)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack (>= 1.0.0)
rack-test (0.5.7)
rack (>= 1.0)
rails (3.0.4)
actionmailer (= 3.0.4)
actionpack (= 3.0.4)
activerecord (= 3.0.4)
activeresource (= 3.0.4)
activesupport (= 3.0.4)
bundler (~> 1.0)
railties (= 3.0.4)
railties (3.0.4)
actionpack (= 3.0.4)
activesupport (= 3.0.4)
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
ruby-freshbooks (0.4.0)
builder (>= 2.1.2)
httparty (>= 0.5.0)
ruby_parser (2.0.5)
sexp_processor (~> 3.0)
sexp_processor (3.0.5)
simple_form (1.3.1)
thor (0.14.6)
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.24)
warden (1.0.3)
rack (>= 1.0.0)
whenever (0.6.2)
aaronh-chronic (>= 0.3.9)
activesupport (>= 2.3.4)
yammer4r (0.1.5)
json (>= 1.1.7)
mash (>= 0.0.3)
oauth (>= 0.3.5)
PLATFORMS
ruby
DEPENDENCIES
bcrypt-ruby
capistrano
devise!
foreigner
haml
haml-rails
hpricot
mocha
mysql2
nifty-generators!
nokogiri
rails (= 3.0.4)
ruby-freshbooks
ruby_parser
simple_form
whenever
yammer4r
This problem is probably very easy to solve but somehow I cannot find a solution.
This happens for BOTH Authlogic and Devise. I have been banging my head against the wall so long that I actually ripped out Authlogic and restarted with Devise -- but experience same problem.
On dev everything is fine.
However, when I get to production, I get this whenever I try to rake db:seed or run the console. This also shows me restarting the server and my gemfile.
Why can't production see the gem? It seems to be able to see the other gems just fine.
The gem you see is the Github version -- this was a recommended fix that does not work for me. I get the same result with the default version, and with forcing a specific version.
The fact that both Authlogic and Devise have the same problem seems to indicate there is some problem with my config on production? What could it be other than the Gemfile?
Dev - Rails 3.0.4, 1.9.2p136
Prod - Rails 3.0.4, 1.9.2p0
Last resort would be upgrading Ruby so they match, but I doubt this is the problem and it would be a lot of work for some reasons I won't go into here.
ops@lightserve2:/home/proj/current$ touch tmp/restart.txt
ops@lightserve2:/home/proj/current$ r c
/home/darkserve/releases/20110217175218/config/initializers/devise.rb:3:in `<top (required)>': uninitialized constant Devise (NameError)
from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/engine.rb:201:in `block (2 levels) in <class:Engine>'
from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/engine.rb:200:in `each'
from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/engine.rb:200:in `block in <class:Engine>'
from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/initializable.rb:25:in `instance_exec'
from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/initializable.rb:25:in `run'
from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/initializable.rb:50:in `block in run_initializers'
from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/initializable.rb:49:in `each'
from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/initializable.rb:49:in `run_initializers'
from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/application.rb:134:in `initialize!'
from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/application.rb:77:in `method_missing'
from /home/darkserve/releases/20110217175218/config/environment.rb:5:in `<top (required)>'
from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/application.rb:103:in `require_environment!'
from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/commands.rb:22:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
ops@lightserve2:/home/darkserve/current$ cat Gemfile.lock
GIT
remote: http://github.com/JonasNielsen/nifty-generators.git
revision: 432d05d55b55e030d6c16b9d71b392181bca45f8
specs:
nifty-generators (0.4.3)
GIT
remote: http://github.com/plataformatec/devise.git
revision: 7113beac81a12da06be2d08bbfaec79017e9fdbf
specs:
devise (1.2.rc)
bcrypt-ruby (~> 2.1.2)
orm_adapter (~> 0.0.3)
warden (~> 1.0.3)
GEM
remote: http://rubygems.org/
specs:
aaronh-chronic (0.3.9)
abstract (1.0.0)
actionmailer (3.0.4)
actionpack (= 3.0.4)
mail (~> 2.2.15)
actionpack (3.0.4)
activemodel (= 3.0.4)
activesupport (= 3.0.4)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4)
rack (~> 1.2.1)
rack-mount (~> 0.6.13)
rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
activemodel (3.0.4)
activesupport (= 3.0.4)
builder (~> 2.1.2)
i18n (~> 0.4)
activerecord (3.0.4)
activemodel (= 3.0.4)
activesupport (= 3.0.4)
arel (~> 2.0.2)
tzinfo (~> 0.3.23)
activeresource (3.0.4)
activemodel (= 3.0.4)
activesupport (= 3.0.4)
activesupport (3.0.4)
arel (2.0.8)
bcrypt-ruby (2.1.4)
builder (2.1.2)
capistrano (2.5.19)
highline
net-scp (>= 1.0.0)
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.0.0)
crack (0.1.8)
erubis (2.6.6)
abstract (>= 1.0.0)
foreigner (0.9.1)
haml (3.0.25)
haml-rails (0.3.4)
actionpack (~> 3.0)
activesupport (~> 3.0)
haml (~> 3.0)
railties (~> 3.0)
highline (1.6.1)
hpricot (0.8.3)
httparty (0.7.4)
crack (= 0.1.8)
i18n (0.5.0)
json (1.5.1)
mail (2.2.15)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mash (0.1.1)
mime-types (1.16)
mocha (0.9.12)
mysql2 (0.2.6)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-sftp (2.0.5)
net-ssh (>= 2.0.9)
net-ssh (2.1.0)
net-ssh-gateway (1.0.1)
net-ssh (>= 1.99.1)
nokogiri (1.4.4)
oauth (0.4.4)
orm_adapter (0.0.4)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack (>= 1.0.0)
rack-test (0.5.7)
rack (>= 1.0)
rails (3.0.4)
actionmailer (= 3.0.4)
actionpack (= 3.0.4)
activerecord (= 3.0.4)
activeresource (= 3.0.4)
activesupport (= 3.0.4)
bundler (~> 1.0)
railties (= 3.0.4)
railties (3.0.4)
actionpack (= 3.0.4)
activesupport (= 3.0.4)
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
ruby-freshbooks (0.4.0)
builder (>= 2.1.2)
httparty (>= 0.5.0)
ruby_parser (2.0.5)
sexp_processor (~> 3.0)
sexp_processor (3.0.5)
simple_form (1.3.1)
thor (0.14.6)
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.24)
warden (1.0.3)
rack (>= 1.0.0)
whenever (0.6.2)
aaronh-chronic (>= 0.3.9)
activesupport (>= 2.3.4)
yammer4r (0.1.5)
json (>= 1.1.7)
mash (>= 0.0.3)
oauth (>= 0.3.5)
PLATFORMS
ruby
DEPENDENCIES
bcrypt-ruby
capistrano
devise!
foreigner
haml
haml-rails
hpricot
mocha
mysql2
nifty-generators!
nokogiri
rails (= 3.0.4)
ruby-freshbooks
ruby_parser
simple_form
whenever
yammer4r
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
任何机会......
Gemfile
Any chance that....
Gemfile
问题原来是这个切片上安装了另一个 Rails 应用程序,并且由于配置错误,rake/rails 在运行时试图调用另一个应用程序的 rake/rails 脚本。
通过在我的应用程序的 /script 目录中强制使用 Rails 脚本,该问题在短期内得到了解决。例如
,而不是
但是,我没有找到一种方法来轻松强制我自己的耙子副本。
The problem turned out to be that there was another rails app installed on this slice, and rake/rails was trying to call the other app's rake/rails script when run due to a misconfiguration.
The problem was resolved in the short term by forcing the rails script in the /script directory of my app. E.g.
instead of
However, I did not find a way to easily force my own copy of rake.