3
votes

I have an application using Rails 2.3.4 which I'm trying to run. No matter how I start it, by using script/console or script/ferret_server, it always boils down to the same error:

uninitialized constant Gem

When I search online, I only find people who has a similar problem finding something inside of the Gem class. But in my case, Gem is just not there at all.

I am running Ruby on Ubuntu. I tried using the version of Ruby that came with APT and a more recent one with RVM. Nothing helped.

Any idea how what can be causing thing and how to fix it? Thanks in advance!

Some extra details, as requested by commenters:

Output of ruby -v:

ruby 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux], MBARI 0x6770, Ruby Enterprise Edition 2011.03

Output of gem -v:

1.8.6

Calling ruby script/console outputs a similar error (edited):

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

I'm trying to call Ferret Server to allow Passenger to connect to it, with the command:

ruby --debug script/ferret_server -e production start

Outputs the following error:

Exception `NameError' at ./script/../vendor/plugins/acts_as_ferret/lib/../../../../config/environment.rb:12 - uninitialized constant Gem
uninitialized constant Gem

Alternatively, calling bundle exec ruby --debug script/ferret_server -e production start outputs the following error:

superclass mismatch for class GemDependency

Please note that I added the following right above the Rails::Initializer.run do |config| line in config/environment.rb:

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')

Remove the lines mentioned above gives uninitialized constant Rails errors instead.

1
I think it will be easier for people to help you if you add the complete error message when you start script/console.Pafjo
Please include the output from ruby -v, gem -v and script/consoleThiago Jackiw
Thanks for your interest. I've added more details to my original post.remino
What's line 12 in environment.rb?Jankeesvw

1 Answers

0
votes

Try putting:

require 'rubygems'

Just after require 'thread'