While looking at how to get syntax highlighted source back up on here after switching to Mephisto, I kept running across references to the Ultraviolet gem. Some of the dependencies are a little old (Oniguruma: Gem, Library), but the output looks very nice, from the examples I'd seen.

The problem comes in, that the Oniguruma gem won't install without you already having the Oniguruma library installed (in a standard system location). This is a pretty well documented problem, with a simple fix.

Unfortunately, I wasn't even able to get the gem to build at all with the original Rakefile that comes with it, and gave up very quickly on trying to fix it. Fortunately, there is a wonderful gem out there called Jeweler. This allowed me to trivially setup a working build environment, drop in the original gem code, and get something up and running.

After adding dir_config to the extconf.rb, you can happily install the Oniguruma gem (provided your LD_LIBRARY_PATH includes wherever you installed the library). This gets to be a problem, when using Passenger on a shared host (such as DreamHost), like I'm trying to do. Fortunately, there's a way to fix this (at least on Linux). When linking in the libraries, you can tell ld to include path information on where to look for them. This is very handy.

Here's the extconf.rb that I ended up going with:


require 'mkmf'
onig_dirs = dir_config('onig')
onig_libs = onig_dirs.pop
ldshared = CONFIG['LDSHARED']
if !onig_libs.nil?
    onig_libs.split(File::PATH_SEPARATOR).each do |p|
        ldshared += " -Wl,-rpath,#{p}"
CONFIG['LDSHARED'] = ldshared
create_makefile( "oregexp" )

With this, I was able to build the gem, install it locally, and still have it work with passenger. I can't guarantee it's the best way to do it, but it works.