Monday, May 21, 2007

Installing Rubygems in a Non-Standard Dir

From the rubygems FAQ: http://rubygems.org/read/chapter/15

You have to redefine the location of the GEM_HOME variable and add the paths to the gem repositories in the RUBYLIB variable before launching the installation into a custom directory.

GEM_HOME should point to $PREFIX/lib/ruby/gems/1.8 if it used with the 1.8 version of ruby.

RUBYLIB should point to the $PREFIX/lib/ruby and $PREFIX/lib/site_ruby/1.8

Here is a shell script that runs in the rubygems distribution directory to install into /home/user :

PREFIX=$HOME
export GEM_HOME=$PREFIX/lib/ruby/gems/1.8
export RUBYLIB=$PREFIX/lib/ruby:$PREFIX/lib/site_ruby/1.8
ruby setup.rb all --prefix=$PREFIX

You may add GEM_HOME and RUBYLIB into your ~/.profile file to automatically load on login.

No comments: