Installing Ruby on Rails on Solaris 10 10/08

Following OpenSolaris rendering itself completely non-booting, I’ve moved back to running Solaris 10 u6 (10/08) on my Ultra20. I’m really not sure what caused the crash, but I couldn’t recover from in the amount of time I wanted to spend (not much) and really I should be focussed on Solaris 10 anyway.

So, how to setup the new box – knowing the end goal is to have a solid development workstation I can use for Ruby, Rails and Solaris development as well as general testing and hacking around… These are my notes. While the end result does work, it took a fair bit of effort getting there. It was a learning experience and ultimately I’m glad of it.

Solaris 10 10/08 Install

First up, the base Solaris install. I chose the “Developer” cluster of packages, it’s pretty much everything except drivers and OEM stuff for hardware I don’t have installed. I realised a bit later that if I wanted to use ZFS on my root disk (which I kind of did), I would have to restart the install in text mode. I didn’t do that this time, so no ZFS root disk for me. Oh well.

Once you’ve got Solaris installed and booting, log in as root. Add

/usr/sfw/bin

and

/usr/ccs/bin

to your PATH.

Fix some library incompatibilities before they become problems…

I learned this the roundabout hard way. In my notebook, this bit is right at the end, but I thought I’d save you the hassle of several extra recompile/test cycles by including it up here.

It seems the default libiconv library in Solaris doesn’t do as much as Ruby and Rails expects it to, so when you go to create a new rails app, ActiveRecord throws a tanty and gives you no joy at all. Basically you see an error along the lines of (Iconv::InvalidEncoding).

Happily, it’s fairly straightforward to fix. We just need to install a copy of the GNU libiconv library.

Grab a copy from sunfreeware.com. I got version 1.11. Extract the archive then change in to the created directory.

./configure --prefix=/usr
make
make install

If you do this at this stage of the install, chances are good that you’ll completely avoid the problems I ran into. This is generally a good thing, but it takes away visability for you of what the problem actually looked like. If you skip this step, get to the end of installing everything and go to create your new rails app and get the Iconv error from ActiveRecord, you simply need to come back to this step, install the GNU libiconv library then recompile & reinstall ruby. You won’t need to reinstall RubyGems or Rails, they’ll use the new Ruby which is using the new libiconv and all will be right in the world.

Compile & Install Ruby

Download and unpack the lastest stable Ruby source code. I went with 1.8.7. Then it’s the usual configure, make, make install routine – watch the –prefix and –exec-prefix options. By default they go to /usr/local. On Solaris it seems to work better as /usr

./configure --enable-pthread --prefix=/usr --exec-prefix=/usr
make
make install

All of the Ruby executables (ruby, irb, etc) should end up in /usr/bin.

Setup RubyGems

Download and extract the lastest RubyGems package. I got 1.3.1. Change into the directory just created and run:

ruby setup.rb

Install Rails

Possibly the easiest part of the whole process:

gem install rails

The particular machine I was installing on sits behind a HTTP proxy, so I needed to add a HTTP_PROXY variable to my environment. Once I’d done that, gem had no problems reaching the outside world.

Did it work!?

mkdir railswork
cd railswork
rails demosite
cd demosite
script/server

You should then be able to access http://localhost:3000/ in your browser and see a Rails “It worked” page. Woohoo! If you don’t, I wish you good luck on your continuing Rails on Solaris education :-)

One Response to “Installing Ruby on Rails on Solaris 10 10/08”

  1. boombinue Says:

    Hi. Your site displays incorrectly in Explorer, but content excellent! Thanks for your wise words:)

Leave a Reply