Ruby 1.8.6 and Oniguruma on OSX

Posted by Tony Buser Tue, 10 Jul 2007 18:26:00 GMT

I'm working on a project that requires some complicated regexes and for the first time actually needed to do a look-behind. Unfortunately, ruby 1.8.6 doesn't support it. You can accomplish it using Oniguruma and Ruby 1.9 will come with it. There's a gem but then you have to specficially reference it and might require code changes when 1.9 comes out(?), not to mention the fact that it's a pain in the ass to install on osx. So I set out to figure out how to recompile ruby with it patched in. The only info I could find in english was for ruby 1.8.5. Finally figured it out, here's how (also works on linux, not just osx):

curl -O ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6.tar.gz
tar xzvf ruby-1.8.6.tar.gz

curl -O http://www.geocities.jp/kosako3/oniguruma/archive/onigd2_5_9.tar.gz
tar xzvf onigd2_5_9.tar.gz
cd oniguruma
./configure --with-rubydir=../ruby-1.8.6
make 186

cd ../ruby-1.8.6
./configure --prefix=/usr/local --enable-pthread --with-readline-dir=/usr/local --enable-shared
make
sudo make install

ruby -e "puts Regexp::ENGINE" # should return Oniguruma
Trackbacks

Use the following link to trackback from your own site:
http://juju.org/articles/trackback/903

Comments

Leave a response, Track co.mments

Comments