In case you're having trouble installing gems...

Posted by chad February 06, 2007 @ 07:54 PM

A significant number of Rails developers have reported problems installing gems with the updated RubyGems release. If you’re experiencing a problem that looks anything like this:

$ gem update sqlite3-ruby Updating installed gems… ERROR: While executing gem … (NoMethodError) undefined   
  method `refresh’ for #

...you should remove your local source_cache file. This is the file that locally caches any gem metadata from the gem server to avoid having to re-download it every time you execute a gem command.

To discover the location of this file on your system, run the following command:

$ gem env
RubyGems Environment:
  - VERSION: 0.9.2 (0.9.2)
  - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8
  - GEM PATH:
     - /usr/local/lib/ruby/gems/1.8
  - REMOTE SOURCES:
     - http://gems.rubyforge.org

The source_cache file should be in the path labeled by GEM PATH. Removing that file should clear up any related issues.

This solution is a workaround pending a fix by the RubyGems team.

Posted in Tools | 16 comments

Comments

  1. Keith Fahlgren on 06 Feb 20:45:

    Ah, thanks. I’ve wondered why no one else mentioned it on ruby-talk and figured it was a local problem

  2. Jamieorc on 06 Feb 22:10:

    On my mac, I’ve used MacPorts to upgrade to rb-rubygems 0.9.1, but whenever I call “gem env” it reports 0.8.11. Anyone else seen something similar? I’ve unstalled every rubygem port and reinstalled the latest with the same result.

  3. dave on 06 Feb 22:14:

    I’ve updated gems to the latest version, but still get the require_gem warning.

    When I do a gem update—system I get:

    Updating RubyGems… ERROR: While executing gem … (NoMethodError) undefined method `refresh’ for #<hash:0x14e78b4>

    Any help is appreciated.

  4. dave again on 06 Feb 22:21:

    I did also delete the source_cache file with the same result.

    If I do a: rails -v I get: /usr/local/bin/rails:17:Warning: require_gem is obsolete. Use gem instead. Rails 1.2.2

    So something didn’t go right.

  5. Jamieorc on 06 Feb 22:33:

    Looks like macports wasn’t cleaning out the old rubygem files. I did “sudo gem update—system” and it’s fine now.

    Then I issued “sudo gem update” and received: “ERROR: While executing gem … (NoMethodError) undefined method `refresh’ for #<hash:0x14fee0c>“

    I cleaned out the source_cache and the command ran fine the second time.

  6. Chad Fowler on 06 Feb 22:36:

    dave again,

    First delete the source cache. Then gem update—system. Then gem install rails -y. That should clean things up.

  7. dave again on 06 Feb 22:48:

    ok. tried that. I do sudo gem update—system and get: Updating RubyGems… Bulk updating Gem source index for: http://gems.rubyforge.org Attempting remote update of rubygems-update ERROR: While executing gem … (Gem::GemNotFoundException) Could not find rubygems-update (> 0) in any repository

    tried that several times and still wont update. I have the latest version so it appears that it’s erroring out that it can’t find a newer one?

  8. Lori Olson on 07 Feb 03:59:

    I’m in the same spot as dave again. Help would be appreciated.

  9. Jeremy Lecour on 07 Feb 10:20:

    Hi, I have a strange problem that I can’t figure out. http://www.ruby-forum.com/topic/95534

    Maybe someone have any clue !

  10. dave again again on 07 Feb 22:09:

    Lori, I ran gem update—system again, but left the source_cache file there. it worked fine, then did a gem update rails -y and rails doesn’t complain anymore about the require_gem stuff.

  11. James Mead on 14 Feb 12:47:

    I found that I also needed to delete another copy of the source_cache file in my ~/.gem directory.

  12. r& on 16 Feb 00:02:

    I’ve deleted both source_caches and updated my system (I’m on gem 0.9.2), and I still get this while trying a bulk update of my gems:

    Attempting remote update of all ERROR: While executing gem … (Gem::GemNotFoundException) Could not find all (> 0) in any repository

    I can install new gems properly, and no longer get require warnings, but this seems slightly strange.

  13. Richard Lennox on 16 Feb 03:17:

    Yup – same problem here. deleted both source_caches and a ‘sudo gem update—system’ gives a

    ERROR: While executing gem … (Gem::GemNotFoundException) Could not find rubygems-update (> 0) in any repository

  14. Runar Ingebrigtsen on 28 Feb 12:39:

    I get this: ERROR: Error installing gem gettext-1.9.0.gem[.gem]: undefined method `include?’ for nil:NilClass

    The problem is that it’s only happening on some computers. I don’t see why this would work randomly.

  15. Joe on 01 Mar 19:37:

    I have a similar issue, but instead I get:

    ERROR: While executing gem … (NoMethodError) undefined method `[]=’ for #

    Any suggestions?

  16. duder on 07 Mar 18:43:

    1. I can’t find the “second” source_cache file, don’t have a ~/.gems directory as specified above

    2. I tried everything here and its still not working – I can’t run the gems update. Without exception I always get the following when I try to do anything “gem __” :

    ERROR: While executing gem … (NoMethodError) undefined method `refresh’ for #<hash:0xb7dcbd58>

    please help!