How to build own Ruby gems

How to build own Ruby gems? Which compiler to use?

asked: 2012-02-06 by: automaciej


Ben Walton answers:

To build/install your own gems, you'll need the CSWrubygems package, which delivers the familiar gem command. This command is setup to use alternatives, so if/when a ruby 1.9 package comes along, gem may refer to the gem19 command. If you need to use the 1.8 version instead, it's also available as gem18.

By default, CSWruby18 wants to build packages with the Sun/Oracle compilers. This is what we used to build the package so the values are hard coded into rbconfig.rb. If you don't have the Sun compiler or would simply prefer to use gcc instead, we ship a version of rbconfig.rb that has usable gcc values. Activate this version with the command:

alternatives --set rbconfig18 /opt/csw/lib/ruby/1.8/i386-solaris2.9/rbconfig.rb.gcc4

Note that when using the gcc version, you may end up with flag conflicts as certain gems rely on a pkgconfig type tool to determine build flags (think postgresql, mysql, etc). You may need to be creative to work around this (or request a packaged gem).


automaciej commented:

The GCC package is called gcc4core. (I assume you don't need C++ to build Ruby gems.)


Dagobert answers:

This doesn't seem to work any more with Ruby 1.9.1