Update: see my recent post describing a better way to do this.

I often need to deploy Ruby gems across many CentOS servers. I prefer to use the native OS package management tools (rpm + yum) rather than using Ruby gems.

Here’s how to build RPMs from Ruby gems using gem2rpm.

I am assuming you have the necessary build tools installed (if not, yum install rpmdevtools) and have already created an RPM build environment, eg:

~/rpmbuild
|-- BUILD
|-- RPMS
|-- SOURCES
|-- SPECS
`-- SRPMS

First, make sure gem2rpm is installed:

yum install rubygem-gem2rpm

Then, grab the gem you want to convert to an RPM:

cd ~/rpmbuild/SOURCES
gem fetch capistrano

This will dump the gem file in the current directory, in this case: capistrano-2.5.14.gem.

Next, create a spec file:

gem2rpm capistrano-2.5.14.gem  > ../SPECS/rubygem-capistrano.spec

Finally, build the RPM(s):

rpmbuild -ba ../SPECS/rubygem-capistrano.spec

4 thoughts on “Building RPMs from Ruby gems

  1. Thank you kind sirs – very useful docs and tools.  The gem2rpm README leaves off enough of the detail that your nice simple walkthough saved a bit of head scratching and hunting around.

  2. good point! I’ll be upgrading my RPMs sholrty with curl support. @TomDV: Thanks for the feedback, the upgraded RPMs will fix the upgrade bug with your patch. Thanks! @gpmidi: The new RPM of 1.8 here will contain proxy. I don’t use it so I didn’t prioritize it, but I have a few requests to make it happen, so it’s coming. 🙂 Will post a update in a new post on my blog. Cheers guys! Keep the feedback coming!

Leave a reply

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

required