Topic: Setting Up Mac OS X 10.5 (Leopard) for Rails Development

Here are directions for setting up Mac OS X 10.5 (Leopard) for developing a Rails web application. This covers everything you need to set up a Macintosh from scratch for Rails development. These instructions are suitable for a developer working offsite or independently (if you're in an office with a support staff you probably don't need this!).

There's a copy of these instructions in a blog post with more readable formatting.

These instructions make a number of assumptions about your development environment and requirements. This is what we use in our own project and is fairly typical. This forum post is something I extracted from a document we keep on hand to set up any new machines for development use.

Here are the instructions...

If the Mac has been used before, and there's reason to save what's already on the machine, back up all the user folders you want to keep to an external drive.

You'll need the disks that came with the Mac or disks from a Mac OS X 10.5 upgrade package. Do an "Erase and Install" to perform a clean install of Mac OS 10.5 (Leopard).

Once the Macintosh HD is selected, click "Options."

Select "Erase and Install."

For "Format disk as" select the default "Mac OS Extended (Journaled)."

Click "OK" and complete the Mac OS X installation.

Create a new account with the name "Computer Administrator" (or something suitable for an account you will only use for system administration) and the short name "admin."

Create any user accounts you'll need for yourself or anyone else using the machine.

From the admin account, install the applications you'll need for development. Here's what we use:

TextMate - http://macromates.com/

iTerminal - http://iterm.sourceforge.net/

Navicat - http://www.navicat.com/

Firefox - http://www.mozilla.com/en-US/firefox/

Firebug - https://addons.mozilla.org/en-US/firefox/addon/1843

Our team uses Skype and Pyro for interteam communication.

Pyro - http://www.karppinen.fi/pyro/

Skype - http://www.skype.com/

I like to use Locomotive as a graphical interface to manage my Rails projects. Before Mac OS X 10.5 (Leopard) was released, Locomotive offered an easy way to install a Rails stack on a Mac. Now it's no longer needed to run Rails but it is still useful as an interface to start and stop an app, open iTerminal or TextMate, and preview an app in a web browser. You might want to try it, though it is not needed. If you are using Locomotive, go to to the Locomotive web site and download and install the "/usr/local" Rails bundle.

From the admin account, install the developer XCode Tools package:

Double click the XcodeTools.mpkg package.

On the "Standard install on 'Mac HD'" screen, select "Customize".

Check "Mac OS X 10.3.9 Support".

Click "Install".

If you'll be working with uploaded images (probably with attachment_fu), you'll need to compile and install FreeImage at a later point in the process, in which case you'll need some header files from an older version of Mac OS X. From the admin account, after installing the XCode Developer package, install the MacOSX10.3.9 developer tools package (this provides the old header files that you'll need for compiling FreeImage later): Double click the  MacOSX10.3.9.pkg file in the packages folder.

Install the X Window System (X11) from the Leopard install disk when you install the XCode developer package:

Install X11Documentation.pkg.

Install X11SDK.pkg.

You'll need MacPorts to later install FreeImage and Git. Install MacPorts 1.5 to "/opt/local" using the package from macports.org:
http://www.macports.org/install.php

Set the "/etc/bashrc" and "/etc/profile" files for the admin user and everyone else.

Set aliases in "/etc/bashrc"

Set the PATH in "/etc/profile"

Modify the PATH environment variable in the "/etc/profile" file to add a path to "/opt/local" for Macports.

Modify the PATH environment variable in the "/etc/profile" file to add a path to "/usr/local/mysql/bin" for MySQL (which you'll add next).

Compile and install MySQL 5.0.45 using the shell script at hivelogic.com: http://hivelogic.com/articles/installin … -mac-os-x/

Check your MySQL version.

In iTerminal, type "mysql --version".

You should see "mysql  Ver 14.12 Distrib 5.0.45, for apple-darwin9.1.0 (i686)".

You may be using Subversion for revision control or you may need to download open source code that is only available via Subversion. Open iTerminal and make sure you have access to Subversion ("which svn").

In iTerminal, type "svn --version"

You should see "svn, version 1.4.4 (r25188)" (or something similar).

You may be using Git for revision control or you may need to download open source code that is only available via Git. Git does not come with Mac OS X 10.5 (Leopard) so you'll need to install it using MacPorts: "sudo port install git-core".

Check your Ruby version.

In iTerminal, type "ruby --version".

You should see "ruby 1.8.6 (2007-09-24 patchlevel 111)
[universal-darwin9.0]".

See which Ruby gems are installed with "gem list --local". If you know which gems you'll need for your application, you can install them now.

Update to the current version of Rails.

In iTerminal, "sudo gem update rails".

In iTerminal, "rails --version" should display "Rails 2.0.2".

If you'll be working with attachment_fu and uploaded images, install Freeimage and Imagescience.

Install Freeimage with "sudo port install freeimage".

If you receive any errors, check the install of XCode Tools.

This discussion may be helpful: http://www.ruby-forum.com/topic/129554

Install Imagescience with "sudo gem install -y image_science".

Log in to your user account and add your applications to the dock for easy access. This is a good time to look in System Preferences and set System/Accounts "Login Items" for applications such as Mail that you want to launch as soon as you log in.

Get Mail set up properly for your user account.

In your user account, set up the web browsers Firefox and Safari (and any others you'll use) in the dock. You may want to set the Firefox home page to "http://localhost:3000/" so you'll see your local development version of the your app when you launch Firefox. It's a good idea to develop in Firefox so you'll be developing to a standards-based browser. You may want to set the Safari home page to your production web site so you can see your app after it is deployed with a non-Firefox browser. Even better, set up Microsoft Internet Explorer running under VMWare Fusion so you check the app for browser compatibility issues.

Set up Navicat to connect to your MySQL databases.

Connect to your development database on "localhost."

You may also use Navicat to connect to your staging or production databases on your hosting server. But unless you have the authority and can take responsibility for the consequences, be cautious about modifying data on the production database!

In your user account, create a folder for your Rails projects.

Open iTerminal, change directories to your Rails projects folder, and create a new Rails application.  Or find an existing open source application at http://github.com/]GitHub and do a "git clone" for an application you want to modify.

Build your Rails app.

Last edited by fortuity (2008-04-22 12:50:05)

Re: Setting Up Mac OS X 10.5 (Leopard) for Rails Development

Are you aware that Locomotive is no longer maintained, and that the Official Mysql package works perfectly well? your instructions seem really complicated...

Last edited by Johnson (2008-04-22 04:40:03)

Re: Setting Up Mac OS X 10.5 (Leopard) for Rails Development

Johnson wrote:

your instructions seem really complicated

Yes, these instructions are overkill for anyone with Mac and Rails experience. Just to be clear, they were originally written for a Java developer who only had experience with Linux and Windows. Hopefully they will be helpful for someone else who needs a similar level of detail.

It'd be great to see some links to simplified instructions for setting up Mac OS X 10.5 for Rails development. Or some suggestions of ways to make the install simpler. For example, what steps could left out?

Re: Setting Up Mac OS X 10.5 (Leopard) for Rails Development

Johnson wrote:

Locomotive is no longer maintained

Good point. I've updated the original document to say:

I like to use Locomotive as a graphical interface to manage my Rails projects. Before Mac OS X 10.5 (Leopard) was released, Locomotive offered an easy way to install a Rails stack on a Mac. Now it's no longer needed to run Rails but it is still useful as an interface to start and stop an app, open iTerminal or TextMate, and preview an app in a web browser. You might want to try it, though it is not needed.

Re: Setting Up Mac OS X 10.5 (Leopard) for Rails Development

fortuity wrote:

It'd be great to see some links to simplified instructions for setting up Mac OS X 10.5 for Rails development. Or some suggestions of ways to make the install simpler. For example, what steps could left out?

There's alway Dan Benjamin's Rails on OSX 10.5 install instructions on Hivelogic - very thorough.

And his Rails on OSX 10.4 install instructions here - for people who haven't upgraded yet.

Re: Setting Up Mac OS X 10.5 (Leopard) for Rails Development

Thanks, Ignition!

Re: Setting Up Mac OS X 10.5 (Leopard) for Rails Development

It'd be great to see some links to simplified instructions for setting up Mac OS X 10.5 for Rails development.

huh? I thought Leopard shipped with Rails? I have Tiger only.

Re: Setting Up Mac OS X 10.5 (Leopard) for Rails Development

I wrote a bit about it here:

http://therailscoder.typepad.com/the_ra … ils-m.html

smile

PJ.

Re: Setting Up Mac OS X 10.5 (Leopard) for Rails Development

1. MacOSX Leopard without any optionals.
2. Updates
3. AppZapper
4. Textmate, Navicat, Pixelmator
5. X11, Xcode3 and MacPorts
6. Ruby and Rails installations
7. Port RMagick and install ImageMagick gem
8. MySQL and install MySQL gem (

sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
or for the 64 bit install
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config )

and set mysql-start and mysql-stop and all the path directories.

That's useally how I do my setup and I think is the most clean one.

Last edited by Aerpe (2008-04-24 08:59:15)

Re: Setting Up Mac OS X 10.5 (Leopard) for Rails Development

Why does no ones use PostgreSQL, it compiles faster, runs great and is meant to be more standards compliant. I use it for all my projects.

Re: Setting Up Mac OS X 10.5 (Leopard) for Rails Development

cherring wrote:

Why does no ones use PostgreSQL, it compiles faster, runs great and is meant to be more standards compliant. I use it for all my projects.

Never tried anything but MySQL sad

Re: Setting Up Mac OS X 10.5 (Leopard) for Rails Development

this is a tut i wish I found this a week ago when I set up my development environment.....
yes it took me a week just to set up o me macbook and still my data base generate some High Version which is wired but over all thing I'm enjoying learning RoR it F*%#ing great!! big_smile

was using drupal but RoR makes me feel a bit more like a real developer not just a designer!