Fixing: undefined method `require_gem’ for main:Object (NoMethodError)

After upgrading to the newest version of rails (2.2.2) I was getting this error:

administrator@shuttle:~$ rails -v/usr/bin/rails:17: undefined method `require_gem' for main:Object (NoMethodError)

Anytime I called “rails” I would get this error and could not get past.

Here is the fix

administrator@shuttle:~/$ sudo vim /usr/bin/rails

Look for anywhere in the file that calls “require_gem”, I found it in only one spot:

require_gem 'rails', version

And change “require_gem” to just “gem” so:

gem 'rails', version

Save and when you run “rails -v” you should see this:

administrator@shuttle:~/$ rails -vRails 2.2.2

You should no longer get the error with running “rails”

Fixing: uninitialized constant Gem::GemRunner (NameError) – Ubuntu

After upgrading to the newest version of rails (2.2.2) I was getting this error:

administrator@shuttle:~/$ gem -v
/usr/bin/gem:10:Warning: Gem::manage_gems is deprecated and will be removed on or after March 2009.
/usr/bin/gem:23: uninitialized constant Gem::GemRunner (NameError)

Anytime I called “gem” I would get this error and could not get past.

Here is the fix

administrator@shuttle:~/$ sudo vim /usr/bin/gem

Change the top of the file to look like this:

require 'rubygems'
require 'rubygems/gem_runner'
#Gem.manage_gems

Save and when you run this you should see this:

administrator@shuttle:~/$ gem -v
1.3.1

You should no longer get the error with running “gem”