James Bowes

Purveyor of Pre-eminent Programmes

Installing ruby gems in your home directory

with one comment

update: This post is now on my new blog.

I found it hard to find good instructions for installing ruby gems as a non-root user without installing the gem package locally as well. Here’s what I figured out; hopefully this will save someone else some time in the future:

Make a directory for gem installation:

$> mkdir ~/.gems

Set up your .gemrc for gem install-time configuration:

$> cat << EOF > ~/.gemrc
gemhome: $HOME/gems
- $HOME/gems
- /usr/lib/ruby/gems/1.8

Set up some environment variables for run-time:

$> cat << EOF >> ~/.bashrc
export GEM_HOME=$HOME/gems
export GEM_PATH=$HOME/gems:/usr/lib/ruby/gems/1.8/
export PATH=$PATH:$HOME/gems/bin

Source your bashrc and you’re all set.

UPDATE (Apr 18, 2009): gem seems to do this on its own now, so just adding

export PATH=$PATH:$HOME/.gem/ruby/1.8/bin

to your .bash_profile should be enough.


Written by jbowes

May 13, 2008 at 10:54 am

Posted in config files

Tagged with , ,

One Response

Subscribe to comments with RSS.

  1. For development you also have the option to build ruby and install it to your homedir. The gem command will install the gems wherever the ruby interpreter that runs it is installed.

    At least for me personally that has helped when I run multiple versions of ruby in development but use RPMs to lay down everything system wide. Whenever I want to use a particular ruby version for development I just set my PATH appropriately.


    May 13, 2008 at 11:16 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: