views:

26

answers:

2

When I upgraded from rubygems 1.3.5 to 1.3.7, my GEM_PATH changed. gem environment gives me

- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- /home/me/.gem/ruby/1.8 

... whereas it was previously /var/lib/gems/1.8

How would you handle this?

  1. I could set GEM_PATH, but this seems a bit messy, as I'd have to do this for my shell, and each of my application's environment.rb files.

  2. I could try to set the default, but I imagine this would involve making changes to default installation files, which seems like a bad idea.

  3. Should I just delete the old dir and reinstall all gems? This sounds safe, but time-consuming.

Thanks for any feedback.

A: 

Avoid the problem by using rvm. You can create and use new gemsets, separate from your current gems.

Brian Maltzan
Thanks for the suggestion. I don't want to maintain multiple gemsets, and it turns out simply copying the old gem dir to the new location works... so far.
+1  A: 

The gem path changing doesn't really have anything do with updating RubyGems. It has to do with the fact that you have two parallel installations of RubyGems: the one from the Debian package repository which you installed via APT and another one.

The solution is simple: Don't Do That.

The Debian RubyGems has been patched to install its gems in /var/lib/gems, the RubyGems from RubyGems.Org uses /usr/lib/ruby/gems if that is writeable, ~/.gem otherwise.

You should never mix several different installations of RubyGems, and you should particularly not mix Debian-RubyGems and plain RubyGems. Either install RubyGems from Debian and use only that, and only update it with APT or install RubyGems from RubyGems.Org and use only that and only update it via gem update --system. Note that this transitively also applies to YARV, which contains its own copy of RubyGems. If you use Debian-RubyGems, then you must also use the Debian-packaged versions of YARV, because only the Debian packages of YARV have been patched to remove RubyGems and use the Debian-provided one.

Somehow, you managed to "update" your Debian-RubyGems to a plain one, which isn't really an update but actually more like a separate installation. This shouldn't actually happen, because the Debian-RubyGems has the update functionality removed. This is what my Debian-installed RubyGems prints:

gem update --system
# ERROR:  While executing gem ... (RuntimeError)
# gem update --system is disabled on Debian. RubyGems can be updated using the 
# official Debian repositories by aptitude or apt-get.

1.3.5 is pretty old, so maybe that error check wasn't in there, although I doubt it. AFAIK that error check was introduced somewhere in the 1.2 timeframe.

Jörg W Mittag
Thanks, I realize now I should not use the Debian repository if I want to control my own fate. Fortunately, I can just move my gems by copying the directory and use the rubygems.org way going forward.