RubyGems: undefined method ‘manage_gems’ for Gem:Module (NoMethodError)

Update: There’s a more efficient solution to this problem here: The Easy Fix

After updating RubyGems I got the following error message:

1
2
/usr/bin/gem:10: undefined method `manage_gems' for Gem:Module (NoMethodError)
#

Nice. So I took a look at the output that was generated and came across this:

1
2
3
4
Deprecation Notices:

* Gem::manage_gems has been removed.
* Time::today will be removed in RubyGems 1.4.

Now what? Right – fix it.

1
sudo vim /usr/bin/gem

Search “Gem.manage_gems” and remove it or replace it with

1
#Gem.manage_gems

Unfortunately i got this

1
2
/usr/bin/gem:23: uninitialized constant Gem::GemRunner (NameError)
#

when running the gems command. After “googling” I came up with this: ¬†

1
sudo vim /usr/bin/gem

inserting

1
require 'rubygems/gem_runner'

so that the first lines of /usr/bin/gem look like this 

1
2
3
require 'rubygems'
require 'rubygems/gem_runner'
#Gem.manage_gems

Fixed.

  • Sebastian

    First of all thanks for the post. Your fix solved my problem at first, but…

    when trying to install rsruby using

    gem install rsruby — –with-R-lib=/usr/lib/R/lib/ –with-R-include=/usr/share/R/include

    I ran into some serious problems – not sure if your fix or a mistake by me applying the fix was the problem – Gem ignored all parameters after “–” so I couldn’t build the native extension because it didn’t find R.h or libR.so (ok this is very specific, but hopefully it will help someone someday)

    I suggest to use the fix of Adam DiCarlo or as a quick fix just paste this into your /usr/bin/gem

    #! /usr/bin/ruby1.8
    #–
    # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
    # All rights reserved.
    # See LICENSE.txt for permissions.
    #++

    require ‘rubygems’
    require ‘rubygems/gem_runner’

    required_version = Gem::Version::Requirement.new(“>= 1.8.0”)
    unless required_version.satisfied_by?(Gem::Version.new(RUBY_VERSION))
    puts “Expected Ruby Version #{required_version}, was #{RUBY_VERSION}”
    exit(1)
    end

    # We need to preserve the original ARGV to use for passing gem options
    # to source gems. If there is a — in the line, strip all options after
    # it…its for the source building process.

    args = ARGV.clone

    begin
    Gem::GemRunner.new.run args
    rescue Gem::SystemExitException => e
    exit e.exit_code
    end

    This code contains some parts from another gem installation and it worked fine for me.

    Cheers

  • http://softwareas.com Michael Mahemoff

    Marcel’s fix worked for me.

  • http://www.entertainmentauthority.info Casey Davis

    Thank you very much; I was just about to get really frustrated, and I’m not a *nix novice either. very helpful!

  • Don

    cheers. great.

  • Nicolas Goles

    Thanks for this :-)

  • http://forrestzeisler.com Forrest Zeisler

    Your a life saver!

  • http://www.flasheves.com eveevans

    thks,
    thats exactly what i was searching for

    and it fixed my issue :)

  • http://blog.kriskemper.com Kris Kemper

    I just wanted to note that I got this error when trying to do a ‘rake rails:freeze:gems’. Another blog out there recommended doing a ‘rake rails:unfreeze’ to fix the problem. In my case, that was all that was needed.

  • jgonzalez

    THANK YOU!!!

  • http://Website Dave

    Nice work, thanks.

    On a more serious note, why does this problem exist in the first place?? Unprofessional.

  • http://itomic.com.au Nick

    Awesome, thanks for the fix!

  • http://Website Cristiano Amaral

    Valeu, matou a pau!

  • http://Website Andy

    Awesome, nice fix!

  • Pingback: /usr/bin/gem:4: undefined method `manage_gems’ for Gem:Module (NoMethodError) « My Blog()

  • http://Website fina

    thanks :)