« Help Desk | Main | My Bookshelf (Part III) »

Xcode 2.2, GCC and Ruby on Rails under Mac OS X Tiger

I wanted to update recently Ruby on Rails to version 0.14.3 (the final 1.0 release seems to be closer than ever) on my Mac, under Mac OS X Tiger 10.4.3 with Xcode 2.2 (the latest version) installed. Well, it turns out to be quite difficult.

First of all, I tried the classic method "sudo gem update" but that won't work, for many reasons:

  1. To begin with, it seems that Xcode 2.2 changes the default path of the fixrbconfig file; thus, you should do the following to fix it:
    1. cd /usr/lib/ruby/1.8/powerpc-darwin8.0 and then
    2. sudo ln -s /usr/lib/ruby/1.8/universal-darwin8.0/* ./; this is because Xcode 2.2 has some additional support for multi-platform development ("Universal Binaries" as Apple calls them) and thus, some paths have changed internally.
  2. Once you've done this, you will re-run "sudo gem update" but it will get stuck when trying to update the mysql gem. To solve this, do the following:
    1. sudo gcc_select 3.3; the default version for Xcode is GCC 4.0.x
    2. sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql --with-mysql-include=/usr/local/mysql/include/ --with-mysql-lib=/usr/local/mysql/lib/ --with-mysql-config=/usr/local/mysql/bin/mysql_config; this way, the mysql gem will be compiled using GCC 3.3
    3. Then, last but not least, sudo gem update should finish updating the other gems without problem :)
  3. Finally, you can reset the GCC 4.0 doing this: sudo gcc_select 4.0

Actually I found another way of correcting it (see comment 55), but it applies only if you use fink.

If someone has problems with these instructions, just leave me a comment.

Update, 2005-11-26: Actually I found out that this problem appears when you have installed Ruby in your system using Fink... since I had installed Fink for getting Maven (that I do not yet use) I just uninstalled and removed Fink from my system, then reinstalled Ruby, RubyGems and Rails, and everything came back to normality.

Update, 2005-12-13: This article is much more comprehensive than mine :) check it out! (Local copy if the link is broken)