What is it?

gem2rpm is a simple utility that transforms rubygems GEM format packages into the equivalent RPM packages.

Why write gem2rpm?

I manage several Linux-based servers and I already spent time making sure that the machines have a local update server, automatically get updates, are monitored, etc. The whole system uses yum and rpm to do its work. I distribute my own software to these machines as rpms.

The problem I had was specifying dependencies between non-ruby and ruby software. If I had a tool that required rake to build it, there was no way to encode that in the RPM spec file. With gems installed via gem2rpm the dependencies can once again be fully specified in rpms.

Where do I get it?


  1. Download the gem2rpm script.
  2. Unpack with gzip, e.g. gzip -d gem2rpm.gz.
  3. Make the script executable, e.g. chmod 755 gem2rpm.
  4. Put the script in /usr/local/bin or your personal bin directory.

Version History

0.3 -- 2006-11-04
Add several command-line switches:

Available as source, gem, and rpm.

0.2.1 -- 2006-07-05
First useful release.

Available as source and gem.


Once you're set up, do gem2rpm your-gem-file-here.gem. This will build an RPM that does mostly what you want.

Inital Setup

To get set up, you'll need an RPM build tree. If you're running a recent Fedora Core release, you can create $HOME/rpmbuild like so:

sudo yum install fedora-rpmdevtools

Otherwise you can build as root (not recommended) or read up about how to set up a non-root rpm build tree. The simplest way to do this is like so:

mkdir $HOME/rpmbuild
cp -r /usr/src/redhat/* $HOME/rpmbuild
echo "%_topdir %(echo $HOME)/rpmbuild" >> $HOME/.rpmmacros

Bootstrapping, or How do I manage everything via rpms?

gem2rpm normally requires rubygems to function. This creates a chicken and egg problem. gem2rpm includes code to make an rpm from rubygems, which is not normally distributed as a gem. To bootstrap the system, assuming you have an rpm build tree in $HOME/rpmbuild, do:

  1. Get gem2rpm, as above.
  2. Get the latest rubygems distribution tgz file from rubyforge. As of rubygems 0.9.0, that would have been rubygems-0.9.0.tgz.
  3. Create an RPM from rubygems-*.tgz, like this:
    gem2rpm -a noarch -g 'System Environment/Base' rubygems-0.9.0.tgz
  4. Install the RPM you built:
    sudo rpm -ivh $HOME/rpmbuild/RPMS/noarch/rubygems-0.9.0-1.noarch.rpm

Or if you're impatient, I keep an rpm of rubygems around too (rubygems-0.9.0-1.noarch.rpm). A big thanks go to Jim Weirich for creating such a useful tool.


Todos/Known Bugs

(In no particular order):

Contact Gil <gil (at) fooplanet (dot) com> with comments, feedback, patches, or suggestions.