Instant Gem Publishing with Gemcutter

ruby gems

Sat Oct 03 07:46:06 -0700 2009

Ruby gem repositories are a bit of a headache right now. The current options:

  • Rubyforge - In addition to being a gem host, Rubyforge has lots of features you may (but probably don’t) care about. Sourceforge-style projects, revision control, mailing lists, and so on. gets in the way of the one thing you certainly DO care about: publishing gems. Putting gems on Rubyforge is a very manual process (though Jeweler and others offer automation workarounds). Gem propagation is slow, as long as 24 hours to propagate to all mirrors.
  • Github - Publish gems to gems.github.com by bumping your revision number and then git push. (Deploying with git push makes sense to me, naturally.) Typically they get built within ten minutes. Github is good for diversity since every fork can have their own gem, but this is its strength as well as its weakness. Having a canonical place to look up the primary version of a gem, in particular for automated dependency resolution, makes Rubyforge still the top pick for publishing major gems.

There’s now a third option in the mix: Gemcutter. Built by Nick Quaranto, this is a dirt-simple, instant-gratification way to publish gems to a canonical source. It offers a flat namespace (like Rubyforge) but without the propagation delay. It’s having your cake and eating it too.

Start Using Gemcutter

  1. Install the latest Rubygems (1.3.3 or greater required):
$ gem update --system
  1. Install the Gemcutter gem from Rubyforge:
$ gem install gemcutter
  1. Use the built-in command to make gemcutter.org your primary gem source:
$ gem tumble

Now any gem you install will come from Gemcutter, taking load off the beleaguered Rubyforge servers. Gemcutter uses S3 for gem storage and transfer, so it’s lickety-split fast and rock-solid reliable.

Publish Your Gems

Gemcutter will make it easier for Rubyists who have never released gems before to get into the game. Here’s how.

Create an account and confirm your email. The first time you use the gem push command, you’ll be prompted for your username and password, which will be saved from then forward - the same pattern as the heroku CLI tool.

To publish, build your gem in the usual fashion (Gem::Specification rake task). Then push out the file (usually landing in a pkg/ subdirectory) to Gemcutter:

$ gem push mygem-0.1.gem

You don’t need to register a project name ahead of time - if the gem name doesn’t already exist, it will be created. It doesn’t get much simpler than that.

Migrate Existing Gems

Gemcutter mirrors Rubyforge, so any gems you’ve released already are available in Gemcutter. But to release new versions of the same gem straight to Gemcutter, you’ll need to take ownership of your gem(s) from your Gemcutter account.

For example, I migrated the Sumo gem like this:

$ gem migrate sumo

You’ll need your Rubyforge credentials (cut-and-pasteable from ~/.rubyforge/user-config.yml if you use the rubyforge gem) in order to make the transfer.