As I promised, here is the second part of my notes on setting up a new Mac. This time I will focus on development tools for Ruby on Rails.


In theory, Ruby is already installed on the Mac. Unfortunately, the bundled Ruby interpreter has some problems, and even if it didn’t, you’d want to use a more up-to-date version than 1.8.2 (which is included in OSX as of Tiger) for Rails development. There are a bunch of ways to install this. Most of them involve recompiling Ruby from scratch, but there are several handy tools that make this process quite painless. The two most prominent ones are MacPorts (formerly DarwinPorts) and Fink. Both provide convenient access to a large set of Unix software. Each distribution has some pros and cons, and overall the choice appears to be pretty subjective. I chose to go with MacPorts mainly because its packages appears to be slightly more up-to-date than Fink. My instructions below are a derived from the official MacPorts installation instructions as well as Robby Russel’s related post, with some adaptations (for example to account for the fact that the latest MacPorts version only comes as a .tar.gz and not as an IMG file).


Before we can install MacPorts, we need to install Xcode. This can be found on the installation DVD, but it is generally recommended to download the latest version from the Apple Developer Tools website (be warned, though: the download weighs in at over 900MB!). Xcode includes many development tools, but most importantly (for our purposes) the GCC compiler that is needed to compile most of the packages that are available via MacPorts.


It may not be strictly necessary for your purposes, but it is recommended to also install the X11 window system in order to be able to run graphical Unix applications. This can be found on the OSX Tiger installation disk (click on the “Optional Installs” package).

MacPorts itself

Now moving on to the actual MacPorts installation. Head over to the MacPorts Download Site, located the latest version (currently 1.3.2) and download the .tar.gz file (here is the most recent as of the time of this writing). Unpack it by double-clicking on the archive. You’ll need to perform the following commands in a shell in order to complete the installation:

cd [wherever you unpacked the DarwinPorts archive]
sudo make install

This installs MacPorts in /opt/local. If you prefer to install it into /usr/local, you can append “–prefix=/usr/local” to the “./configure” command above.

Since MacPorts is installed in /opt/local, you will need to add this directory to your path. You will also need to set the DISPLAY environment variable in order to run X11 applications. Using a text editor, create a file named “.profile” in your home directory and add the following two lines:

export PATH=/opt/local/bin:/opt/local/sbin:$PATH
export DISPLAY=:0.0

In your shell, you’ll now need to type “source .profile” in order for these changes to take effect right away in your current session (or simply start a new one). Note: Alternatively, you could put these lines into /etc/profile, which would make MacPorts available to all users.

Next you may want to update MacPorts (it might already be up-to-date, but just in case):

sudo port selfupdate

Now you’re all set for installing all kinds of cool Unix tools via MacPorts. The general syntax is “sudo port install [name]”, so whenever you’re looking for a particular application, chances are that this command will do the trick.


Use the following command to install Ruby and RubyGems via MacPorts:

sudo port install ruby rb-rubygems

Be prepared to wait for a while… When this completes, type “ruby -v” to confirm that you are now using the upgraded Ruby version (currently 1.8.5).


Now that RubyGems is installed, we’ll use this to install Rails and all its dependencies:

sudo gem install -y rails


You will need to install a database in order to build any meaningful Rails applications. Mysql and Postgresql are popular choices (and you will probably want to deploy your application on one of these databases), but for Rails development I generally favor Sqlite because of its small footprint and easy installation. Installing it is as simple as:

sudo port install sqlite3

Sit back and enjoy!

You should now be all set for Rails development on your Mac. Feel free to follow the steps in Robby’s instructions to create an initial Rails app, but replace “postgresql” with “sqlite3”.

There are of course many other tools that you may want to install for development (such as RadRails), but I’ll cover these another time.