Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

path

ruby

gem

I manually built Ruby 1.9.2 on Snow Leopard. Now I can’t find my old GEM files. I’m guessing they're in a different path now or something. So I have three questions:

  • What is the "old" gem path, where gem install sinatra puts the sinatra gem?
  • What is the "new" gem path, which is set when I build Ruby manually?
  • How do I change it so Ruby finds my gems again?
like image 418
MrB Avatar asked Nov 20 '10 13:11

MrB


People also ask

Where do RubyGems get installed Mac?

If you use the Mac system Ruby, running gem install will try to save gems to the system Ruby directory /Library/Ruby/Gems/2.6. 0 . That directory is owned by root , the system superuser. Ordinary users are not allowed to write to it (and you really shouldn't alter this folder).

Where are gem packages installed?

When you use the --user-install option, RubyGems will install the gems to a directory inside your home directory, something like ~/. gem/ruby/1.9. 1 . The commands provided by the gems you installed will end up in ~/.

What is RubyGems on Mac?

RubyGems is a package manager for the Ruby programming language that provides a standard format for distributing Ruby programs and libraries (in a self-contained format called a "gem"), a tool designed to easily manage the installation of gems, and a server for distributing them.


1 Answers

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.

like image 174
jason.rickman Avatar answered Sep 28 '22 22:09

jason.rickman