Ruby on Rails on Solaris x86

The last few days I have fought with getting ruby and rails to run on a Solaris host, and let me tell you it isn’t easy!

The worst problems to tackle were:

  1. readline is not working properly
  2. libiconv is not working properly
  3. nothing is in the effing PATH

readline

Okay it is really nessessarry but to be frank irb without readline support sucks. So first of all the task is to get a up to date readline library, good news are Solaris is a Unix related OS so it is not much of a problem.

wget ftp://ftp.cwru.edu/pub/bash/readline-6.0.tar.gz
gzcat readline-6.0 | tar xf -
cd readline-6.0
configure: ./configure --prefix=/opt/readline
make
sudo make install

There we go you now have the latest readline library!

libiconv

This one is more tricky, at least to figure out it is actually messed up. The symptoms were that my rails told me:

method 'camelize' for 'app':String not found

Hey of cause that means the libiconv is missing … narf … to be honest I’d hat hoped that the rails libs, that are not loaded because libiconv isn’t there complain instead of silently dieying but well – I figured it out… So same procedure as libreadline:

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.9.1.tar.gz
gzcat libiconv-1.9.1.tar.gz | tar xf -
cd libiconv-1.9.1
configure: ./configure --prefix=/opt/readline
make
sudo make install

bringing it together

Now we have all the libs, next task is to compile ruby. But beware it is important to tell ruby where to find the libraries as it won’t go looking for them on it’s own.

export CFLAGS="-I/opt/iconv/include/ -L/opt/iconv/lib -L/opt/readline/lib -I/opt/readline/include/readline" 
export CPPFLAGS="-I/opt/iconv/include/ -L/opt/iconv/lib -L/opt/readline/lib -I/opt/readline/include/readline" 
export LDFLAGS="-L/opt/iconv/lib -R/opt/iconv/lib -L/opt/readline/lib -R/opt/readline/lib"

This takes care of the library locations next to compile ruby itself, which is quite easy:

./configure --prefix=/opt/ruby --enable-pthread
make
make install
Done, the --enable-pthread option is only needed for ruby 1.8.* ruby 1.9.1 seems to detect that on it's own. Now you can go and install rails via gems and it works like a charm :)

Posted by Heinz N. 'Licenser' Gies Wed, 29 Apr 2009 07:23:00 GMT


Trackbacks

Use the following link to trackback from your own site:
http://blog.licenser.net/trackbacks?article_id=53