How to Setup Your Mac for Rails Development

June 29, 2012 Tanzeeb Khalili

This guide will show you how to setup your Mac environment for optimal Ruby on Rails development.

Step 1: Package Manager

Homebrew is the best package manager for Mac OS X. You will need it to get the rest of the packages in this guide. Follow the simple instructions here to install it on your system.

Once you’ve installed Homebrew, run the following command to make sure it is working correctly:

$ brew doctor

The first time you run it, you will get an error like the following:

Error: /usr/bin occurs before /usr/local/bin

Edit your /etc/paths file to look like this:


Restart your shell and run brew doctor again. It should say:

Your system is raring to brew.

You are now ready to install packages on your Mac:

$ brew install git mercurial

Step 2: Ruby

The default Ruby on Mac OS, version 1.8.7, is outdated for most Rails projects. The best way to upgrade is to install Ruby via a package manager.

This tutorial will show you how to install Ruby 1.9 with rbenv, but you can alternatively use RVM. Run the following:

$ brew install rbenv ruby-build

Note: In the output of the previous command, you will see a message like this:

==> Caveats
To enable shims and autocompletion, add rbenv init to your profile:
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

Pay close attention to these caveats! Homebrew uses these messages to give you further instructions for configuring your package. In this case, add the specified line to your ~/.bash_profile (create the file if it does not exist) and restart your shell.

Once you’ve installed rbenv, you are ready to install Ruby 1.9. Run rbenv install to see a list of rubies available. Install the latest version you see:

$ rbenv install 1.9.3-p194

Set this version as your default:

$ rbenv global 1.9.3-p194

Running ruby -v should give you the version you just installed. Install some useful gems:

$ gem install bundler pry

Step 3: Databases

This command will install some common databases:

$ brew install postgres mysql mongodb redis memcached

You only need to install the packages you need. Remember to follow the instructions in the caveats! For example, you will need to run the following for memcached:

$ mkdir -p ~/Library/LaunchAgents
$ cp /usr/local/Cellar/memcached/1.4.13/homebrew.mxcl.memcached.plist ~/Library/LaunchAgents/
$ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist

If you missed the caveats for any of the packages, eg. mysql, run brew info mysql to see it again.

Step 4: Shell

As a Rails developer, you will spend a lot of time in the shell. The following tools and tweaks will make your life easier. The final product should look similar to this:


TotalTerminal is “a system-wide terminal available on a hot-key”. It is highly customizable and works with the default

Bash Prompt

Having an informative prompt is extremely useful for keeping track of your development. In my prompt, I list my current directory, ruby version and source control branch.

In order to display information about the version control in the current directory, you will need vcprompt:

$ brew install mercurial # if you didn't get this from Step 1
$ brew install --HEAD vcprompt

Add the following lines to your ~/.bash_profile:



Feel free to to tweak it to your liking. Note that if you are using RVM instead of rbenv, your prompt will need a different command.


I find tomorrow-theme‘s color scheme very pleasing. To install, just clone the repository and open Tomorrow Night.terminal in Finder.

Add the following line to your ~/.bash_profile to add color output to some default commands (like ls):

export CLICOLOR=1

The following command will add color to your git output:

$ git config --global color.ui true


Bash, the default shell, has very good autocompletion support. To enable it, install bash-completion:

$ brew install bash-completion

Add the following snippet (mentioned in the caveats) to your ~/.bash_profile to enable homebrew’s built in auto-completion:

if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion

You can now auto-complete most packages installed by homebrew. For example, type git checkout<tab> to have it prompt you with a list of checkout targets.


If you want your shell to be even more configurable, you may want to look into zsh. Oh-my-zsh is a good starter configuration for this extremely powerful and configurable bash alternative.

Step 5: Editor

Flamewars can start over the choice of an editor so we are going to avoid one here. If you like IDEs, try RubyMine, and if you like GUI-based text editors, try Sublime Text. They are both fantastic.

I like Vim, so I will go through my preferred Vim configuration for Rails development.


MacVim is a gVim compatible vim frontend for Mac. Install it with Homebrew:

$ brew install macvim


Janus is a curated list of useful vim plugins. It is highly configurable, so you can easily add your own configurations and add/remove other plugins. Installation instructions can be found on its Github page. A small list of plugins it includes by default:

  • Rails.vim, for navigation, syntax highlighting and a lot more (eg. :Rake to run tests on the current file)
  • Fugitive.vim, awesome vim integration
  • NerdTree, file explorer
  • Ack.vim, fast file search
  • ctrl-p, fuzzy file finder

You can find the full list of features here. A few additional plugins:

$ mkdir ~/.janus && cd ~/.janus
$ git clone # Syntax highlighting for Slim templates
$ git clone   # Easy formatting for tables, useful for Cucumber features

And a beautiful color scheme:

$ cd tomorrow-theme # wherever you cloned it from Step 4
$ cp vim ~/.janus/tomorrow-theme
$ echo color tomorrow-night > ~/.vimrc.after


That’s it! You are now ready to develop Ruby on Rails applications on your Mac:

$ git clone && mvim sample_app

About the Author


More Content by Tanzeeb Khalili
New MBA plus Migration Assistant can lead to runaway Dock process
New MBA plus Migration Assistant can lead to runaway Dock process

With the power contained in the newest 13" MacBook Airs l was ready to give up my 27" iMac for a laptop plu...

Future-proofing Your Apps: Cloud Foundry and Node.js
Future-proofing Your Apps: Cloud Foundry and Node.js

Most real-world applications we ship to consumers or enterprises are multi-year projects. In the cloud era,...

Enter curious. Exit smarter.

Register Now