Ultraviolet on FreeBSD

Subscribe to Ultraviolet on FreeBSD 3 post(s), 2 voice(s)

 
Avatar Geoff 71 post(s)

Not sure if its required in warehouse 1.1.2 and onwards, it might fall back to the javascript code highlighter if it can’t find ultraviolet. I’ve not checked.

At any rate this is how you get ultraviolet highlighting to work on FreeBSD. Ultraviolet depends on Textpow which depends on the Oniguruma gem which only works with the Oniguruma library v5.9.0 or later. There is no devel/oniguruma5 port so things aren’t as easy as we are often used to.

You really have two choices, you can either follow on or you can build oniguruma 5.9.0 with a prefix of `/usr/`. I personally prefer not messing up the FreeBSD file system hierarchy.

First step is to download Oniguruma 5.9.0 from http://www.geocities.jp/kosako3/oniguruma/

$ tar zxf onig-5.9.0.tar.gz
$ cd onig-5.9.0
$ ./configure
$ make
$ sudo make install

then keep the directory around as you can `make clean` later to remove it if you wish.

Now comes the more annoying part, I’ve tried every combination of setenv, export, inline define of CFLAGS and LDFLAGS I can think of to get the oniguruma gem to find oniguruma.h to no avail instead I had to manually patch part of the oniguruma gem then rebuild and install it.

$ sudo gem install oniguruma

this will fail but its alright we don’t mind. We’ll be fixing that momentarily…

$ sudo gem unpack oniguruma
$ cd oniguruma-1.1.0/ext

this should extract a copy of oniguruma-1.1.0 into your present directory and changed into the ext directory of the gem. If this doesn’t unpack the gem into your current directory then you can do the following

$ cp -R /usr/local/lib/ruby/gems/1.8/gems/oniguruma-1.1.0 ./

Now we need to change the file extconf.rb to read as follows

require 'mkmf'
Config::MAKEFILE_CONFIG["CFLAGS"] << ' -I/usr/local/include -Wall'
Config::MAKEFILE_CONFIG["LDFLAGS"] <<' -L/usr/local/lib'
init_mkmf
have_library("onig")
create_makefile( "oregexp" )

This tells mkmf when it generates the makefile to look in /usr/local/include for the oniguruma header file. Now we can do the following to rebuild and install our patched version of the gem. Assuming you are still in the `ext/` directory

$ cd ..
$ rake package
$ rake install_gem

You can now install the textpow and ultraviolet gems

$ sudo gem install ultraviolet -y

and you should be good to go with ultraviolet highlighting.

 
Avatar rick Administator 546 post(s)

Awesome. This was a lot more involved than installing it on OSX

We won’t make ultraviolet required, just a nice-to-have. Maybe when Ruby 1.9 is out and common we can do that (since the onigurama lib is bundled with 1.9 apparently).

 
Avatar Geoff 71 post(s)

The only real issue with the stock gem is the lack of searching /usr/local/include for the oniguruma header file.

I’m hoping Rails and family will be able to work pretty well with Ruby 2.0 when it finally hits us. Even then though I suspect we will still need the Oniguruma gem until either the Textpow gem is updated to use the system regex engine or someone writes a compatibility layer to go between system regex and the ORegexp stuff that Textpow wants.