Aston J

Setting up a Ruby dev enviroment on Lion

Posted on: November 24th, 2011 by AstonJ 3 Comments

This post is part of my series on Clean Lion install for Ruby Development.

Next we’ll set up our fresh dev enviroment for Ruby. Here we’ll cover installing and setting up:

  • GCC (or Xcode)
  • Homebrew
  • Xcode
  • Rbenv or RVM
  • Ruby 2.1.3
  • Rubygems
  • Rails
  • POW – Optional
  • MySQL & Unix set-up


Install the latest version of Xcode (or if you don’t want to, see here for other options). Once Xcode has installed, open it, then go to preferences > downloads, and install command line tools, or enter this in terminal:

xcode-select --install


In the terminal copy and paste the following:

ruby -e "$(curl -fsSL"

That’s it!

Rbenv or RVM Rubygems, Rails, Git, ImageMagick

Choose either Rbenv OR RVM (I’m using RVM because it’s what works better on my server)

For Rbenv

In terminal:

brew update
brew install rbenv
brew install ruby-build

Then for Ruby and Rubygems:
(It may take a while installing Ruby)

rbenv install 2.1.3
rbenv rehash
rbenv global 2.1.3

Note that ‘rbenv rehash’ has to be run each time you install a new Ruby. Rbenv global sets the global Ruby. Open up .bash_profile in a text editor and if the following lines are not present, add them:

export PATH="$HOME/.rbenv/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
eval "$(rbenv init -)"


\curl -sSL | bash -s stable
rvm install 2.1.3
rvm use --default 2.1.3

Update RubyGems

gem update --system

Now for Rails:

sudo gem install rails

Then ImageMagick and Git:

brew install ImageMagick
brew install git

Restart terminal and check your versions by:

ruby -v
rails -v

And you should be all ready to go. Check out the full install guides here.

Optional: POW

In terminal:

curl | sh

Then when you need to create sym links for your apps:

ln -s /path/to/your_app ~/.pow/your_app

Optional: Xcode

If you need it, and haven’t installed it in the first step of this post, simply download and install from the app store.

MySQL & Unix set-up

I’ve put this in a separate post: How to install MySQL on Lion

Why not give PostgreSQL a try? Most Rails devs now seem to be using it, you can find install instructions and options here: How to install PostgreSQL on Mac OS X

Tags: , , ,
  • Jeff Hertzler

    I’m no expert here, but is adding

    eval “$(rbenv init -)”

    to your ~/.bash_profile a requirement? I couldn’t get ‘ruby -v’ and ‘which ruby’ to use the correct version until i added it.

    Other than that, your instructions were the most concise and easy to follow I found online for getting rails set up using rbenv and homebrew.

    • AstonJ

      Hi Jeff

      Sorry, yes you need that – it’s covered in the ‘MySQL & Unix’ set-up – the last part of the guide, although in a seperate post: (I’ll add a note in the post above to draw attention to it).

      Thanks – I’m glad you found the article useful!

  • Karl

    I prefer

    It is meant for Rails, but installs everything necessary to a Ruby Environment in one install. :)