$GEM_HOME makes ruby programming even better

Ruby is by far one of my favourite programming languages. It combines the power of Perl with the flexibility of Lisp while remaining far more readable than either.

The downside of this though is that a great deal of Ruby development is done in conjunction with the Gem package manager. At best you are asked for the root password and the the /usr directory gets polluted by packages that aren’t part of your distribution and potentially changes behaviour for other users on the system.

The simple solution to this is to add the following into your profile script:

if which ruby >/dev/null && which gem >/dev/null; then
export GEM_HOME=$(ruby -rubygems -e ‘puts Gem.user_dir’)
export PATH=$GEM_HOME/bin:$PATH
export GEM_PATH=$GEM_HOME:$GEM_PATH
fi

By Ryan McCoskrie

Founder of the Hurunui Tech Club Creator of Vicinitude President of the Leithfield Public Library

Leave a comment