我有一个使用Rails 2.3.4的应用程序,我正在尝试运行 . 无论我如何启动它,通过使用脚本/控制台或脚本/ ferret_server,它总是归结为同样的错误:
未初始化的恒定宝石
当我在网上搜索时,我只发现在Gem课程中发现类似问题的人 . 但就我而言,宝石根本就不存在 .
我在Ubuntu上运行Ruby . 我尝试使用APT附带的Ruby版本和最近使用RVM的版本 . 什么都没有帮助 .
知道怎么可能导致事情以及如何解决它?提前致谢!
根据评论者的要求,一些额外的细节:
输出 ruby -v :
ruby 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 2011.03
输出 gem -v :
1.8.6
调用 ruby script/console 会输出类似的错误(已编辑):
Loading development environment (Rails 2.3.4)
/var/www/sites/example.com/releases/20110726061310/config/environment.rb:12:NameError: uninitialized constant Gem
/usr/local/rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/irb/init.rb:254:in `require': no such file to load -- console_app (LoadError)
from /usr/local/rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/irb/init.rb:254:in `load_modules'
from /usr/local/rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/irb/init.rb:252:in `each'
from /usr/local/rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/irb/init.rb:252:in `load_modules'
from /usr/local/rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/irb/init.rb:21:in `setup'
from /usr/local/rvm/rubies/ree-1.8.7-2011.03/lib/ruby/1.8/irb.rb:54:in `start'
from /usr/local/rvm/rubies/ree-1.8.7-2011.03/bin/irb:17
我试图通过以下命令调用Ferret Server以允许Passenger连接到它:
ruby --debug script/ferret_server -e production start
输出以下错误:
Exception `NameError' at ./script/../vendor/plugins/acts_as_ferret/lib/../../../../config/environment.rb:12 - uninitialized constant Gem
uninitialized constant Gem
或者,调用 bundle exec ruby --debug script/ferret_server -e production start 会输出以下错误:
superclass mismatch for class GemDependency
请注意,我在 config/environment.rb 的 Rails::Initializer.run do |config| 行上方添加了以下内容:
require 'thread'
if Gem::VERSION >= "1.3.6"
module Rails
class GemDependency
def requirement
r = super
(r == Gem::Requirement.default) ? nil : r
end
end
end
end
require File.join(File.dirname(__FILE__), 'boot')
删除上面提到的行代替了 uninitialized constant Rails 错误 .