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 https://panel.dreamhost.com – For e.g., I have created the sub-domain gems.humbug.in. We will use that for all code examples.
- SSH into your server and create a
gemsdirectory under the domain/sub-domain directory
ssh -l USERNAME DOMAIN_ADDRESS For e.g. ssh -l gems gems.humbug.in cd gems.humbug.in mkdir gems
- Open another terminal and copy all the custom gems on your local system into the
scp XXXX.gem [email protected]:~/gems.humbug.in/gems
- Go back to the terminal where you have SSH running and run the equivalent of the following commands:
cd; gem generate_index -d gems.humbug.in
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.
Add it to Heroku
.gems gem manifest file as described here. Add the following line for every gem you want to install from the repository.
GEMNAME -v VERSION -s DOMAIN/SUBDOMAIN For e.g. libxslt-ruby -v 1.1.1 -s http://gems.humbug.in/
Hope this helps. Leave a comment if you get stuck anywhere.