Using Local Gems on Dreamhost
12 December 2009, late morning
This was tripping me up this morning. Dreamhost doesn’t have a lot of rubygems I use installed for everyone to use. I have gem installing rubygems in my home directory, under $home/local/gems
. You do this by setting the environment variable GEM_HOME
. In Bash, I have the following in my .bashrc
file: GEM_HOME="$HOME/local/gems"
. In order for passenger to use your local gems when it is running a ruby web application, you need to set the variable ENV['GEM_PATH']
in your Ruby script. An alternative would be to “vendor” all the gems you need to use — that is storing them locally and referring to them explicitly. This seemed like pain in the ass. To see this all in action, here is rackup file I use to run the Sinatra app that is currently running blansdowne.ca.
Update Dec 18 2009: This looks to barely work. For reasons I haven’t quite sorted out, you end up with random Rack errors on occasion. I suspect it’s because Dreamhost isn’t the sort of place to host Ruby applications, but whatever.
Update Dec 21 2009: I think a more complete solution looks to be outlined here I’ve updated my Rackup file as well.