Host Custom Gems with Dreamhost – Your Own Gem Server

I have started working on a webapp on Heroku. Heroku requires you to specify where your external gems come from. This is nice as you can specify a RubyForge, RubyGems, GitHub or any repository for that matter. However RubyGems is the de-facto gem host these days. All the gems on RubyGems have owners/co-owners and only they can update/upgrade the gem. Now what happens if you have a lazy gem owner who hasn’t updated the gem for over 2 years? You get an outdated gem. The only option is to update the gem yourself and host it elsewhere. Thats what made me create my custom gem server on Dreamhost.

Install a Custom Repository on Dreamhost

  • Create a domain/sub-domain at – For e.g., I have created the sub-domain We will use that for all code examples.
  • SSH into your server and create a gems directory under the domain/sub-domain directory
    For e.g.
    ssh -l gems
    mkdir gems
  • Open another terminal and copy all the custom gems on your local system into the ~/ folder.
    scp XXXX.gem
  • Go back to the terminal where you have SSH running and run the equivalent of the following commands:
    cd; gem generate_index -d

Thats it, we have a functional custom gems repository. Anytime you add/delete gems from this repository, rerun the gem generate_index command as shown above.

Update your sources

Now you can either use this as a secondary source repository for the bundler or add it to the gems manifest file so that heroku can install it directly from the repository you just created.

Add it to the Bundler

To add it to the bundle, just add a line in your Gemfile.

source ''

Add it to Heroku

Create a .gems gem manifest file as described here. Add the following line for every gem you want to install from the repository.

For e.g.
libxslt-ruby -v 1.1.1 -s

Hope this helps. Leave a comment if you get stuck anywhere.

1 comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.