---
title: 2009 Rubyist's Guide To A Mac OS X Development Environment
teaser:
tags: web,ruby,vim,osx
author: Dan Croak
published_on: 2009-03-30
---

*Update: A better approach is detailed in [Laptop Setup for an Awesome
Development Environment][laptop].*

[laptop]: https://thoughtbot.com/blog/laptop-setup-for-an-awesome-development-environment

My hard drive kicked the bucket recently. From scratch, here's how I quickly got
my Ruby web development environment into ship-shape form The thoughtbot Way.

Many of these instructions are specific to Mac OS X 10.5 (Leopard). Some of them
are opinionated (Vim over Textmate).  Pick-and-choose what you need but this is
**everything** that I use happily day-to-day right now.

I chose the quickest, easiest approach to installing everything. I'm not an
operating system whiz. I want a fun, powerful, working environment for
developing Rails apps.

The community moves fast so this won't be current for long. I give 75% of it a
shelf-life of a year.

## Git

Simple. [Download the installer](http://code.google.com/p/git-osx-installer/)
and run it.

Lots of important gems we use in Rails apps are on github so let's add it to our
gem sources:

    sudo gem source -a http://gems.github.com

Maybe the best part about git is its branching capabilities. One particularly
awesome gem that **makes branching easier** is:

    sudo gem install webmat-git_remote_branch

That gets you stuff like:

    grb create branch_name [origin_server]

Create a new local branch as well as a corresponding remote branch based on the
branch you currently have checked out. Track the new remote branch.  Checkout
the new branch.

## SSH

### Public key

I need a public key to get access to private github repositories.

    ssh-keygen

Hit enter over and over until it's done doing its thing.

### Forwarding

Occasionally I need SSH forwarding. This adds my key to the OS X keychain. Set
it and forget it.

    /usr/bin/ssh-add -K

### Aliases

You've got a few servers. Open up `~/.ssh/config` and create some aliases for
servers you want to be able to quickly ssh into:

    Host nytimes_staging
      HostName staging.nytimes.com
      User developer

    Host nytimes_production
      HostName nytimes.com
      User developer

## thoughtbot/dotfiles

We've written previously about [configuring
vim](https://thoughtbot.com/blog/thoughtbot-is-filled-with-vim-and-vigor) and
[configuring irb and
script/console](https://thoughtbot.com/blog/irb-script-console-tips). We
maintain an excellent [set of
configurations](http://github.com/thoughtbot/dotfiles) for vim, irb, git, zsh,
and more.

Clone the repo:

    git clone git://github.com/thoughtbot/dotfiles.git

Run the installer:

    ./install.sh

This sets up the appropriate symlinks (`~/.vimrc`, `~/.irbrc`, etc.). As
`thoughtbot/dotfiles` is improved, just keep pulling the repo. If you want to
make changes, fork the repo (and send us pull requests).

Go the extra mile and get ack, a fast tool for searching through files:

```bash
curl http://ack.googlecode.com/svn/tags/latest/ack > ~/bin/ack && chmod 0755 ~/bin/ack
```

Note that you'll need the ~/bin directory for that to work:

    mkdir ~/bin

One reason to get ack is that when you're working in your Rails app, move your
cursor over a variable or method name, type `Shift-K`. That will search in your
project, using ack, for that variable or method name. This is part of
`dotfiles`.

The `dotfiles` use zsh. Here's how to change the default Mac OS X shell to zsh:

    chsh -s /bin/zsh

## Xcode Tools

It's generally good to have the Xcode tools installed if you're doing serious
programming on Mac OS X. You will explicitly need it if you want to use MySQL
with Ruby. The mysql gem needs to be compiled and won't work without it. Pop in
your Mac OS X Install Disc 1 and run the XcodeTools installer:

[![xcode install](http://images.thoughtbot.com/ui/2009-4-1-Picture_2.png)](http://images.thoughtbot.com/ui/2009-4-1-Picture_2.png)

## MySQL

First, download the **package** for [OS X 10.5 86 32 bit](http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.35-osx10.5-x86.dmg/from/pick#mirrors).

Run the installer.

Install the MySQL gem so you can use MySQL with versions of Rails `>= 2.0`.

    gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

## Rubygems

The version of Rubygems that comes with Leopard is out of date. Update it.

    sudo gem install rubygems-update
    sudo update_rubygems

Here's a buffet of gems you're likely to use. `sudo gem install` any that look
interesting:

    cheat (1.2.1)
    cucumber (0.3.0)
    faker (0.3.1)
    geokit (1.3.0)
    giraffesoft-timeline_fu (0.1.1)
    github (0.1.1)
    heroku (0.6.1)
    json (1.1.6)
    mislav-hanna (0.1.7)
    nokogiri (1.2.2)
    passenger (2.1.2)
    rack (0.9.1)
    rails (2.3.2)
    railsmachine (1.0.5)
    RedCloth (3.0.4)
    redgreen (1.2.2)
    reek (1.1.3)
    rest-client (1.0.1)
    right_aws (1.10.0)
    right_http_connection (1.2.4)
    rr (0.7.1)
    rspec (1.2.0)
    sinatra (0.9.1.1)
    technicalpickles-le-git (0.2.0)
    thoughtbot-factory_bot (1.2.0)
    thoughtbot-paperclip (2.2.7)
    thoughtbot-shoulda (2.10.1)
    webmat-git_remote_branch (0.3.0)
    webrat (0.4.3)
    wirble (0.1.2)

## ImageMagick

We use [Paperclip](http://github.com/thoughtbot/paperclip) for file uploads in
Rails apps. It requires Imagemagick, which is much less painful to install than
RMagick.

[Download and unpack this tarball](http://www.imagemagick.org/download/binaries/ImageMagick-universal-apple-darwin9.7.0.tar.gz).

Follow [these
instructions](http://www.imagemagick.org/script/binary-releases.php).

## Firefox & Firebug

If you're a web developer, you need Firebug (or the new [developer tools in
Safari 4](http://www.apple.com/safari/features.html#developer)). Inspect is your
friend.

* [Install
  Firefox](http://www.mozilla.com/en-US/products/download.html?product=firefox-3.0.8&amp;os=osx&amp;lang=en-US).
* [Install Firebug](http://getfirebug.com/)

## Sphinx

[Sphinx](http://www.sphinxsearch.com/) is a dependency on a couple of projects
I've seen recently. It seems to be the preferred full-text solution for Rails
developers these days. Install it if you need it:

    curl -O http://sphinxsearch.com/downloads/sphinx-0.9.8-rc2.tar.gz
    tar zxvf sphinx-0.9.8-rc2.tar.gz
    cd sphinx-0.9.8-rc2
    ./configure
    make
    sudo make install

## S3 Hub

[S3 Hub](http://s3hub.com) is a desktop application for managing your [Amazon
S3](https://aws-portal.amazon.com/gp/aws/developer/subscription/index.html/104-4018257-4816762?serviceID=8&amp;servicePlanID=6&amp;tag=ducktyper-20)
buckets. It's really clean and easy to use.

## Go forth & conquer

This will more than get you off the ground for Ruby web development on a Mac OS
X. Please add any other tips & tricks you might know of in the comments.
