A tutorial on how to set up The Wonderful World of Ruby and Rails™ on OS X
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Leaving Kansas

How to set up The Wonderful World of Ruby and Rails™ on OS X.

Supported: 10.6 Snow Leopard and 10.7 Lion. Sorry, no 10.5 Leopard and so far not tested on 10.8 Mountain Lion.

1. Prepare and Install

  • Tools

    Check out Markdown and install Mou. Also install iTerm2 and Sublime Text.

  • OS X

    Update to latest version of 10.6 Snow Leopard or 10.7 Lion.

  • XCode

    You will find this at the Mac App Store. It's huge. This will take some time to download.

    We also need the Command Line Tools for Xcode from within Xcode's Download preferences:

  • Finder

    Make hidden files visible by pasting this into the terminal

      $ defaults write com.apple.Finder AppleShowAllFiles YES

    and restart the finder:

    Then activate keyboard control for system dialogues:

  • Homebrew

    is currently installed by doing:

      $ /usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"

    after which

      $ brew doctor

    should happily announce that:

      Your system is raring to brew.    

    Homebrew installs packages into /usr/local/bin, so we need to edit the file /etc/paths to tell the system to look there first. Open /etc/paths with Sublime Text. On a fresh Lion install that file should look something like this:


    That last line /usr/local/bin needs to go to the top, so the file looks like this:


Save the file (will ask for your admin password) and restart the terminal.

  • git

    We want to uninstall the git version that came with OS X and install an up-to-do version with homebrew:

      $ which git

    will output (on Lion at least)


    so we need to do

      $ sudo rm -rf /usr/bin/git

    to remove the old git and

      $ brew install git

    to install the new version. Now you can do

      $ git --version


      $ which git
  • rbenv + rubybuild

      $ brew install rbenv
      $ brew install ruby-build

    We now need to edit the bash profile which doesn't exist on a fresh system. Do:

      $ touch ~/.bash_profile

    paste the line

      eval "$(rbenv init -)"

    into it and restart the terminal.

      $ rbenv versions

    shows nothing. We need to install a Ruby into rbenv by doing:

      $ rbenv install 1.9.3-p194

    This may take a while. Then do:

      $ rbenv versions

    which should output:



      $ rbenv global 1.9.3-p194
      $ rbenv versions
      $ rbenv version
  • Bundler


      $ gem install bundler

    and restart the terminal. Note: if you get a permission error, you must do sudo gem install bundler –– same with other gems.

  • the heroku cli

      $ gem install heroku

    and restart the terminal. Then do:

      $ heroku login

2. Fork and deploy a test app

  • create a folder called my_awesome_blog in your projects-folder

  • log into github

  • go to https://github.com/5v3n/karathy

  • fork and clone it into ~/projects/my_awesome_blog

  • install needed gems with bundler:

      $ cd ~/projects/my_awesome_blog
      $ bundle install
  • create a new heroku app:

      $ heroku create
  • push your app online:

      $ git push heroku master
  • Open the URL in your browser.

Do you see your new blog? Congratulations #1!

3. Run the app locally on your machine

You don't have to push every change to Heroku to check it out. You can run a server on your very own machine.

  • Install thin:

      $ gem install thin

    and restart the terminal.

  • go to your blog directory and start the server:

      $ cd ~/projects/my_awesome_blog
      $ thin start
  • open in your webbrowser

Do you see your local copy of the blog? Congratulations #2!

4. Mod it

Do you see your changes? Congratulations #3!

Have a look at the terminal window where you started thin. You can see the requests your local server is answering.

Now commit and push:

    $ git commit -am "Effyeah, my first commit evah!"
    $ git push heroku master
    $ git push origin master

Do you see your changes on your deployed version of the blog and on your github repo? Congratulations #4!

You did it! Now take a break,…

…get a beer and pat yourself on the back for next couple hours.

Useful stuff



A very special thanks to 5v3n. This doc originated as part of documentation for The Ratpack Workshop.

Also thanks to the Hamburg Ruby Community, especially blindgaenger and the mindmatters crew.

HT to Ben for the hint on enabling keybard control for all system dialogues.

Further reading and links

(more coming. maybe.)