Skip to content

Undefined method `require_gem' for main:Object

Posted on 31 January 2008

To update an old app to Rails 2.x you will need to change 'require_gem' to just 'gem'.

Otherwise you will get: Undefined method `require_gem' for main:Object

View the snippets archive ››

8 comments made

rupher commented on 31 Jan 08 at 07:50

I recently had this problem. I think the new version of rubygems use gem instead of require_gem. It’s not necessarily a Rails 2.x issue.

Jeremy commented on 01 Feb 08 at 18:05

Actually, the new version of gems only requires a “require.” No gem or require_gem method needed. Just do this: require ‘rubygems’; require ‘yourlib’;

Reinhart commented on 09 Apr 08 at 00:25

gem install—remote rake

I have been your problem before, and after i did it, it’s worked well.

ken commented on 10 Apr 08 at 19:35

Great. Thanks, all. I was stumbling blindly, then found this.

Rob commented on 05 Jun 08 at 02:00

I had to use “gem” to get this to work:

!/usr/bin/env ruby

require ‘rubygems’ gem ‘multi’
  1. require ‘multi’ # didn’t work require ‘amulti’

multi(:fib,0){1} multi(:fib,1){1} multi(:fib,Integer){|n|fib(n-1)+fib(n-2)}

puts fib(4)

Rob commented on 05 Jun 08 at 02:22

sorry the formatting was messed up. I pasted the code on these to pastebins: http://code.bulix.org/ckqjv9-66832 http://www.pastebin.org/40737

jeff commented on 10 Jun 08 at 09:44

I am new to RoR. After getting everything installed, I ran … rails sandbox

I received the error you reported. This is what fixed the issue for me … gem update rails

swinful commented on 28 Jul 08 at 19:20

Thanks!!! Saved me a million!!

Got something to say?

About

Paul is a web developer for Kyanmedia web agency. He's lucky enough to write in Ruby on Rails full-time and uses this site to post snippets of code.

Contact

my name at gmail.com

More snippets

Take a look in the archive

Need a website?

Contact my employer. Make sure to check out our portfolio of work.

Hosting

I recommend hostingrails.com