Installing Ruby Gems locally on a shared host
Posted by Tim Riley Tue, 28 Mar 2006 14:06:00 GMT
This took a little bit of fiddling around. On the Dreamhost servers which host my sites, there are many Ruby gems installed, but I wanted to install a couple of extra ones locally that were required by a few specific apps.
You can set $GEM_HOME and $GEM_PATH environment variables in order to customise where the gem command looks for gems. $GEM_HOME is the gem installation directory, where new gems will be installed, and $GEM_PATH is a colon-separated list of places on the system to look for already installed gems.
To install the extra gems locally, I needed to set $GEM_HOME to point to some place within my home directory. However, the gem command expects a sources gem to be installed (which provides a list of remote gem download sources), and it will refuse to find it outside of $GEM_HOME, even if it is installed somewhere in your $GEM_PATH. So, you need to install it locally as well, before installing your extra remote gems.
Here is how I did it:
mkdir -p ~/apps/lib/gems/1.8/cacheexport GEM_HOME=$HOME/apps/lib/gems/1.8export GEM_PATH=/usr/lib/ruby/gems/1.8cp /usr/lib/ruby/gems/1.8/cache/sources-0.0.1.gem ~/apps/lib/gems/1.8/cachegem install sources --localgem install my_new_gem
Next, I need to figure out if there are any tricks required in order for Ruby apps to see and use these additional gems. However, that is for another night!
In other news, Rails 1.1 is out! Check out this post for a good rundown of what is new.
Did you end up getting this to work on dreamhost?
I get this error: ERROR : Local gem file not found: sources*.gem when I try to gem install sources—local.
I’d be interested to know if it ended up working.