Where are the GEMs when Ruby compiled manually in Mac OS X 10.6.8? Where are the GEMs when Ruby compiled manually in Mac OS X 10.6.8? ruby ruby

Where are the GEMs when Ruby compiled manually in Mac OS X 10.6.8?


Typing gem env (Using your old Ruby install's gem command) at a command prompt gives something similar to:

> RubyGems Environment:>   - RUBYGEMS VERSION: 1.3.6>   - RUBY VERSION: 1.9.1 (2009-07-16 patchlevel 243) [i386-mingw32]>   - INSTALLATION DIRECTORY: C:/Ruby19/lib/ruby/gems/1.9.1>   - RUBY EXECUTABLE: C:/Ruby19/bin/ruby.exe>   - EXECUTABLE DIRECTORY: C:/Ruby19/bin>   - RUBYGEMS PLATFORMS:>     - ruby>     - x86-mingw32>   - GEM PATHS:>      - C:/Ruby19/lib/ruby/gems/1.9.1>      - C:/Users/Username/.gem/ruby/1.9.1>   - GEM CONFIGURATION:>      - :update_sources => true>      - :verbose => true>      - :benchmark => false>      - :backtrace => false>      - :bulk_threshold => 1000>   - REMOTE SOURCES:>      - http://rubygems.org/

(On Windows... I imagine Snow Leopard will have a similar format)

The GEM PATHS field is the interesting thing here. If you go to those directories listed, you should see a folder named cache. That will contain a list of .gem files corresponding to all the installed gems in that specific directory. You should just be able to call gem install *gemname* on each of those gem files (using your new Ruby install's gem command).

EDIT: Mistakenly referred to INSTALLATION DIRECTORY instead of GEM PATHS. Greg reminded me that there are multiple locations known by a specific installation of Rubygems. All of those locations needs to be checked for gems used by that installation of Ruby.


Your "old" gems would be relative to the Ruby that came bundled with the Mac because the gem command is included with Ruby 1.8.7, which is stock on Snow Leopard. If your which ruby shows /usr/bin/ruby, your gem environments should be similar to:

- GEM PATHS:   - /Library/Ruby/Gems/1.8   - /Users/greg/.gem/ruby/1.8   - /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8

If you are using RVM you might be able to tell it to copy your gems from the system gemset to one under RVM's control. I haven't tried doing that as I install RVM immediately and let it handle all my Ruby installation and then I ignore the system's installation.

If your which ruby shows /usr/local/bin/ruby then the gem env command should reflect the changed path for the version you compiled from source.

I'm curious WHY you would build it manually, when RVM is available to handle all the configuration and installation, and largely remove any concerns about where things are and whether you've just stomped on the system's installed version.

When RVM has installed a Ruby version, it will all be in ~/.rvm and your Gems will be nicely located there too. You'll be able to manage the gems as gemsets, relative to each version of Ruby, and switch back and forth instantly. Or, even better, you can run a command/program in each version of Ruby you have installed to test them using rvm ruby 'some command'.

Notice in the above gem env output that gems are in three separate areas on the disk. Under RVM's control they're in RVM's sandbox:

- GEM PATHS:   - /Users/greg/.rvm/gems/ruby-1.9.2-p0   - /Users/greg/.rvm/gems/ruby-1.9.2-p0@global

That makes it trivial for me to back them up, or blow them away if I want to.

I used to compile my rubies from source on my Macs and Linux boxes. I use RVM for that now. It's so much better than doing it by hand.


I believe the standard gem install path on OS X is:

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/