Logged in as member ericArmstrong
(logout)

InstallingRubyGems (Ruby)

Review | More ...
HomePage | RecentChanges | Preferences | Wikis | RubyGarden | Feed-icon-16x16

Once RubyGems is installed, installing any particular gem (3rd party Ruby extension or library) is as easy as issuing a command like one of these:
  % gem install rake
  % gem install rails --include-dependencies

RubyGems finds the extension in the current directory, or goes to the web and installs from there. The gem then becomes part of your Ruby libraries. From then on, you can update all installed extensions to the latest versions with a single command:

  % gem update

  Note: You'll want to keep track of the extensions
  you've added, since they become part of the Ruby 
  installation. When you upgrade to a later version, you'll
  want to reinstall the extensions, which will probably have
  been upgraded to work with the new version.

As with the InstallingRuby page, this page was motivated by the need to install Ruby in a non-standard location on a Solaris system. But the instructions should work with little change on Linux or OS/X.

  Acknowledgments: The information in this page came
  almost entirely from fellow Sun Rubyist Vladimir Sisikov.
    --eric Armstrong

Standard Installation

RubyGems is described here: http://docs.rubygems.org/read/book/1

The standard RubyGems installation is described here: http://docs.rubygems.org/read/chapter/3

Those instructions work well when Ruby has been installed in the standard location (/usr/local/bin), but if you need to install to a non-standard location, follow the instructions below.

Non-Standard (Solaris) Installation

To add RubyGems to a non-standard ruby installation, follow the instructions below.

1. Define GEM_HOME to point to lib/ruby/gems. For example, if ruby is installed at /some/path/ruby/1.8.4:

   sh: export GEM_HOME=/some/path/ruby/1.8.4/lib/ruby/gems
  csh: setenv GEM_HOME /some/path/ruby/1.8.4/lib/ruby/gems

2. Add ruby and the future gems bin to your path. For example, if /some/bin has a symlink to the ruby executable:

   sh: export PATH= /some/bin:$GEM_HOME/bin:$PATH
  csh: setenv PATH  /some/bin:$GEM_HOME/bin:$PATH

3. Download the rubygems zip file from http://rubyforge.org/frs/?group_id=126

4. Unzip the zip file and go to the directory:

  % unzip rubygems-0.8.11
  % cd rubygems-0.8.11

5. Install gems:

  % ruby setup.rb config --prefix=$GEM_HOME
  % ruby setup.rb setup
  % ruby setup.rb install

Set up your environment

These settings let you use the gem installer and access installed gems:

1. Add ruby and future gems' bin dir to path. (Already done, if you just installed gems.) For example,if /some/bin has a symlink to the ruby executable:

   sh: export PATH= /some/bin:$GEM_HOME/bin:$PATH
  csh: setenv PATH  /some/bin:$GEM_HOME/bin:$PATH

2. Make ruby aware of gems when it runs:

   sh: export RUBYOPT=rubygems
  csh: setenv RUBYOPT rubygems

3. Tell ruby where to find installed gems:

   sh: setenv RUBYLIB=$GEM_HOME/lib/ruby/site_ruby/1.8/
  csh: setenv RUBYLIB $GEM_HOME/lib/ruby/site_ruby/1.8/

  Note: It should be possible to avoid this step, 
  but I do not yet know how. This setting isn't needed 
  when installing to the standard location on Windows. 
  (There, setting RUBYOPT is sufficient.)

4. If you're behind a firewall, duplicate the proxy settings from your browser so RubyGems can get out to the web:

  sh: export HTTP_PROXY="http://your.proxy.url:8080"
 csh: setenv HTTP_PROXY "http://your.proxy.url:8080"

HomePage | RecentChanges | Preferences | Wikis | RubyGarden
Edit text of this page | View other revisions
Rev 6, Last edited at June 02, 2006 05:19 am by ericArmstrong / 69.107.92.170(diff)
Find: