RubyGem版本错误:rails(1.2.3 not> = 3.0)

时间:2012-03-14 17:17:04

标签: ruby-on-rails rubygems gem mongrel

我正在维护一个古老的RoR网站,我们正在重写Django。当Rails处于起步阶段时,该网站是由其他人编写的,没有人保持更新直到我到达它。一两个晚上,服务器出现故障,我怀疑是由于MySQL的更新。在尝试修复它的过程中,我们打破了它,现在杂种不会启动。我在杂种日志中看到了这一点:

/home/USER/rails/SITE/config/boot.rb:26:Warning: Gem::SourcUSERdex#search support for String patterns is deprecated, use #find_name
/usr/local/lib/site_ruby/1.8/rubygems.rb:812:in `report_activate_error': RubyGem version error: rails(1.2.3 not >= 3.0) (Gem::LoadError)
    from /usr/local/lib/site_ruby/1.8/rubygems.rb:223:in `activate'
    from /usr/local/lib/site_ruby/1.8/rubygems.rb:258:in `activate'
    from /usr/local/lib/site_ruby/1.8/rubygems.rb:257:in `each'
    from /usr/local/lib/site_ruby/1.8/rubygems.rb:257:in `activate'
    from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:33:in `require'
    from /home/USER/rails/SITE/config/environment.rb:24
    from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require'
    from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:29:in `require'
    from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:147:in `rails'
    from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:113:in `cloaker_'
    from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:149:in `call'
    from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:149:in `listener'
    from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:99:in `cloaker_'
    from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:50:in `call'
    from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:50:in `initialize'
    from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:84:in `new'
    from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:84:in `run'
    from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/command.rb:212:in `run'
    from /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
    from /usr/local/bin/mongrel_rails:19:in `load'
    from /usr/local/bin/mongrel_rails:19

我四处搜寻,并试图诊断错误。看起来mongrel希望我们拥有rails 3+这是不可能的,因为我们将在短短几周内更换网站并且不想打扰它更新(它只需要现在工作)。如何强制mongrel运行当前版本的rails?

config/environment.rb中,我们有RAILS_GEM_VERSION = '1.2.3' unless defined? RAILS_GEM_VERSION我认为会强制使用Rails 1.2.3。此外,这是gem list

的输出
*** LOCAL GEMS ***

abstract (1.0.0)
actionmailer (3.2.2, 3.0.3, 1.3.3)
actionpack (3.2.2, 3.0.3, 1.13.6, 1.13.3)
actionwebservice (1.2.6, 1.2.3)
activemodel (3.2.2, 3.0.3)
activerecord (3.2.2, 3.0.3, 1.15.6, 1.15.3)
activeresource (3.2.2, 3.0.3)
activesupport (3.2.2, 3.0.3, 1.4.4, 1.4.2)
acts_as_ferret (0.5.3, 0.4.3)
arel (3.0.2, 2.0.7)
builder (3.0.0, 2.1.2)
bundler (1.1.0, 1.0.9)
cgi_multipart_eof_fix (2.5.0)
daemons (1.1.8, 1.1.0)
erubis (2.7.0, 2.6.6)
fastthread (1.0.7)
ferret (0.11.6)
gem_plugin (0.2.3)
hike (1.2.1)
i18n (0.6.0, 0.5.0)
jk-ferret (0.11.8.3, 0.11.8.2)
journey (1.0.3)
json (1.6.5)
mail (2.4.3, 2.2.15)
mime-types (1.17.2, 1.16)
mongrel (1.1.5)
multi_json (1.1.0)
polyglot (0.3.3, 0.3.1)
rack (1.4.1, 1.2.1)
rack-cache (1.2)
rack-mount (0.8.3, 0.6.13)
rack-ssl (1.3.2)
rack-test (0.6.1, 0.5.7)
rails (1.2.3)
railties (3.2.2, 3.0.3)
rake (0.9.2.2, 0.8.7)
rdoc (3.12)
sprockets (2.1.2)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10, 1.4.9)
tzinfo (0.3.32, 0.3.24)

感谢您的帮助!


好的,我明白了。这是不相容的宝石。幸运的是,我们有一个测试服务器和一个生产服务器。我们昨晚只与测试服务器混淆了(生产服务器上的杂种正在运行),所以我在两台服务器上都进行了gem list,结果发现测试服务器有一个完全不同的列表。我刚刚在测试服务器上安装和卸载了gem,直到gem list在两台服务器上生成了相同的列表。

1 个答案:

答案 0 :(得分:1)

Mongrel确实需要最新的rails版本,但你的应用程序需要rails 1.2.3,所以存在冲突。

避免宝石冲突的最简单方法是使用不同的gemsets(使用rvm或rbenv)。如果不使用,请移除导轨3 gem ...