Advice for handling default GEM_PATH
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 pr开发者_运维技巧eviously /var/lib/gems/1.8
How would you handle this?
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.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.
Should I just delete the old dir and reinstall all gems? This sounds safe, but time-consuming.
Thanks for any feedback.
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.
Avoid the problem by using rvm. You can create and use new gemsets, separate from your current gems.
精彩评论