Using your distributions version of rubygems has some drawbacks:
- root permission needed when installing gems
- shared by all users
- shared by all projects
- when backing up a project, the system wide rubygems are often overlooked
Therefore, I’ve switched to project specific installations of rubygems (and one installation for everyday usage). By using modules it’s even easy to switch between projects.
First install ruby and some required dependencies:
sudo apt-get install ruby libyaml-ruby libzlib-ruby
Download and extract the latest rubygems version:
mkdir ruby_test
cd ruby_test
wget http://rubyforge.org/frs/download.php/35283/rubygems-1.1.1.tgz
tar zxvf rubygems-1.1.1.tgz
Create a modules file for easy loading:
#%Module1.0
set BASEDIR /path/to/ruby_test/rubygems
setenv RUBYOPT rubygems
setenv GEM_HOME ${BASEDIR}/gem_repository/
prepend-path PATH ${BASEDIR}/bin
prepend-path RUBYLIB ${BASEDIR}/lib
Note that the rubygems tarball extracted to rubygems-1.1.1, while the base directory is set to /path/to/ruby_test/rubygems. The rubygems-1.1.1 tree will be used to install rubygems into the latter directory.
If you named your module file ruby, you can now load it with:
module load ruby
With the environment variables set, install rubygems:
cd rubygems-1.1.1
ruby setup.rb --prefix=/path/to/ruby_test/rubygems
and clean up:
cd ../
rm -rf rubygems-1.1.1.tgz rubygems-1.1.1.
From this point on, you can use your newly installed rubygems, e.g. for installing wirble (tab completion and syntax coloring in irb).
gem list -r
gem install wirble
The RubyGems User Manual provides more information if needed.