I needed to install Rails and FXRuby on a couple of my Mac OS X boxes. They are all running Tiger (10.3). I used the Apple development tools that come on the install CD. (I did try the latest dev tools from Apple’s site. I had some problems — probably solvable problems — but the older dev tools were just fine for me, so I rolled back.)
Before you dive into this, ask: do I really want to do this all “by hand?” There are alternatives that install and configure Rails and other Unix software for you. Consider the excellent Locomotive package. DarwinPorts is another good option, although the Fox Ruby packages were an older version (1.2) last time I checked. Finally, there is Fink. Fink is similar to DarwinPorts, although there doesn’t seem to be as much RUby interest there.
Ezra Zygmuntowicz has the best instructions for Rails on OS X that I’ve found. Building Ruby, Rails, LightTPD, and MySQL on Tiger is also helpful. Rather than repeat these instructions, I just added some notes from my experience.
OS X comes with ruby installed in /usr/bin. This version doesn’t work so well with the Ruby MySQL bindings and readline. It’s easy to replace with a new copy straight from the source.
You want to make sure OS X will use your version of Ruby. And unless you want to muck around with add “–prefix=” to everything you compile, add a couple lines to your PATH in your ~/.bash_login file:
At least for me, curl needed the ‘–location-trusted option’ to download files from Ruby Forge:
curl --location-trusted -O http://rubyforge.org/frs/download.php/2338/ruby-1.8.2.tar.gz
The SSL patch to Ruby 1.8.2 gave me the following compilation error, so I didn’t use it:
ossl_x509store.c:541: error: 'struct x509_store_ctx_st' has no member named 'param'
It’s entirely possible this patch is very important, but I’m not doing anything with Ruby and SSL right now.
Without the SSL patch, there was a new error:
readline.c:780: error: 'rl_event_hook' undeclared (first use in this function)
So I installed a new (GNU!) version of readline:
curl -v -O http://ftp.gnu.org/pub/gnu/readline/readline-5.1.tar.gz
tar zxvf readline-5.1.tar.gz
GNU readline built and installed without any problems, and then Ruby built fine as well.
Download MySQL 4.1
Add “/usr/local/mysql/bin” to your PATH in .bash_login.
Download MySQL bindings directly, not as a gem
ruby extconf.rb --with-mysql-config
Sure you don’t want to use DarwinPorts? OK.
Fox requires several image libraries you probably don’t have installed already. I grabbed the versions from the Fox download page and they build and installed with minor tweaks.
The TIFF lib needs a newer version of config files and LZW:
cp /usr/share/libtool/config.guess .
cp /usr/share/libtool/config.sub .
cp libtiff-lzw-compression-kit-1.3/tif_lzw.c tiff-v3.5.7/libtiff/
./configure --enable-shared --enable-static --prefix=/usr --with-opengl=no --x-includes=/usr/X11R6/include
Test from the Terminal:
There’s a gem, but I used the source instead.
ruby install.rb config -- --with-fox-include=/usr/include/fox14 --with-fox-lib=/usr/lib/fox14
ruby install.rb setup
sudo ruby install.rb install
As a side note, I later enabled font anti-aliasing with XFT using “–with-xft” when I built Fox. But I needed to install several dependencies via DarwinPorts before I could get it to work