---
title: 2011 Rubyist's Guide To A Mac OS X Development Environment
teaser:
tags: web,ruby,osx
author: Dan Croak
published_on: 2011-08-09
---

*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

It's been [two and a half
years](https://thoughtbot.com/blog/post/159805668/2009-rubyists-guide-to-a-mac-os-x-development)
since my last laptop. It's neat to look back and see how much has improved
since then for setting up a Ruby development environment.

Of particular note, Homebrew, RVM, and Bundler did not exist back then.

Here's how I set up an OS X 10.7 (Lion) thoughtbot laptop in 2011.

## GCC

I need GCC to help install everything else so I downloaded [GCC for
Lion](https://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.7-v2.pkg).

We used to have to install Xcode to get GCC [when OS X wasn't for
developers](http://zachholman.com/2011/03/osx-isnt-for-developers/), which was
a 3-4GB download and took 10GB+ of space. Buzzkill.

However, [Kenneth Reitz](https://github.com/kennethreitz), one of the
[Readability](http://www.readability.com/) guys, fixed this with his [OS X GCC
installer](https://github.com/kennethreitz/osx-gcc-installer), which is a
comparatively svelte 272MB download.

Later on, when we're installing things using Homebrew, we'll see warnings like:

    Xcode is not installed! Builds may fail!

But, the builds will build fine.

While that's installing, we'll customize our environment a little.

## SSH

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

    ssh-keygen -t rsa

I'm kept hitting "enter" until it was done. Alternatively, I could have brought
my old SSH key over but I’m not into
[falconry](http://tinyrobots.thoughtbot.com/post/8643506214/matt-explains-why-you-should-keep-your-ssh-keys-on-a).

## dotfiles

We have a standard set of configurations for vim, irb, git, zsh, and more.

I cloned the repo:

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

I ran the installer:

    ./install.sh

This sets up the appropriate symlinks (`~/.vimrc`, `~/.irbrc`, etc.). I'll stay
up-to-date and contribute using the
[fork-track-update](https://github.com/thoughtbot/dotfiles/blob/master/README.md)
flow described in the README.

## zsh

Our `dotfiles` assume zsh so I switched from the bash default to zsh:

    chsh -s /bin/zsh

## Re-map Caps Lock to Control

We're pretty much all vim users here so it's nice having super-quick home-row
access to the `Control` key... and who uses Caps Lock, anyway?

    System Preferences > Keyboard > Modifier Keys

## git

Already installed by default, but I set the global config:

    git config --global user.name "Your Name" git config --global user.email
you@example.com

## Heroku accounts

I'm using Heroku for all my apps right now. However, thoughtbot's clients and
even our own apps like [Trajectory](https://www.apptrajectory.com) are not
owned by my Heroku account. So, it comes in handy to be able to switch to a
different account on a project basis.

    heroku plugins:install git://github.com/ddollar/heroku-accounts.git heroku
accounts:add dan  --auto heroku accounts:add thoughtbot  --auto heroku
accounts:add client  --auto heroku accounts:default dan

## thoughtbot's laptop script

Once GCC is downloaded and installed, I'm ready for the heavy-duty installation
using our [laptop script](https://github.com/thoughtbot/laptop).

    bash < <(curl -s https://raw.github.com/thoughtbot/laptop/master/mac)

This installs:

* Homebrew (for managing operating system libraries)
* Postgres (for storing relational data)
* Redis (for storing key-value data)
* Ack (for finding things in files)
* tmux (for saving project state and switching between projects)
* ImageMagick (for cropping and resizing images)
* <abbr title="Ruby Version Manager">RVM</abbr> (for managing versions of the
  Ruby programming language)
* Ruby 1.9.2 stable (for writing general-purpose code)
* Bundler gem (for managing Ruby libraries)
* Rails gem (for writing web applications)
* Heroku gem (for interacting with the Heroku API)
* Taps gem (for pushing and pulling <abbr title="Structured Query
  Language">SQL</abbr> databases between environments)
* Postgres gem (for making Ruby talk to <abbr title="Structured Query
  Language">SQL</abbr> databases)

It took about 15 minutes for everything to install.

While it's running, it copies your SSH key to the clipboard and opens your
Github SSH page. Paste your SSH key so your Github account is authenticated to
your machine.

## Caveats

We wrote a laptop script because we help hundreds of people a year get a Ruby
development environment set up at [workshops](http://workshops.thoughtbot.com)
and [Boston Ruby hackfests](http://bostonrb.org/project_night). One time we set up
[30 business school students' laptops in 3
hours](https://web.archive.org/web/20120226193221/http://www.techmediaclub.com/2011/04/everybody-codes-at-hbs-coding-bootcamp/).

If you read our source, you'll see it it's very simple but more invasive than,
say, the excellent [Cinderella](http://www.atmos.org/cinderella/) by [Corey
Donohoe](https://github.com/atmos), which uses Chef to keep your machine tidy.
We're assuming the person definitely wants a "thoughtbot laptop".

## DIY

It's pretty easy to write a wrapper that installs Homebrew, RVM, and your
favorite databases and gems so consider forking [our
project](https://github.com/thoughtbot/laptop) and writing your own script,
just like you might write your own Rails template script like
[Suspenders](https://github.com/thoughtbot/suspenders).
