Installing Ruby On Rails On A Mac

Installing Rails can be one of the trickiest things to overcome for a newbie to Ruby and Ruby on Rails. Being an open source project with lots of dependencies is a great strength for Rails and allows it to innovate quickly, but it has the unfortunate side effect of making a prospective developer jump through a lot of hoops, particularly for someone new to programming or new to the Unix/Linux world.


Windows users are in luck as there is a great, no hassle installer available at This is about as easy as it gets for installing Rails; unfortunately, my experience on a Windows laptop (even one with an SSD) is that Rails development can be painfully slow due the large amount of file I/O that Rails development entails.


This is bound to change, and I had to rewrite some of these instructions over the course of installing Ruby on Rails on a couple of different Macs with different versions of OS X and XCode. But here is what worked for me on Mountain Lion (OS X 10.8) and XCode 4.5.2. There are a couple of terms and concepts to be familiar with.

  • XCode is Apple’s development environment, primarily used for creating iOS and Mac apps, but it includes some system libraries that you need for our Rails development.
  • Homebrew is a package environment for OS X that can install most other missing system packages you’ll need for Rails
  • RVM (Ruby Version Manager) is highly recommended as it lets you manage different versions of Ruby, Rails and Gems so you can try out new versions or mimic different production environments without having to install/reinstall everything.

Installing Rails

Install XCode:

  • Click and install XCode from the Mac Store
  • Once installed, go to Preferences -> Downloads -> Install Command Line Tools

Please note that the next several installation commands should be run in the Terminal application.

Install Homebrew and apple-gcc42
This installs the Homebrew package manager and a GCC compiler

$ ruby -e "$(curl -fsSkL"
 $ brew tap homebrew/dupes
 $ brew install apple-gcc42
 $ sudo ln -s /usr/local/bin/gcc-4.2 /usr/bin/gcc-4.2

Install RVM:
In the OS X Terminal, issue the following commands:

$ curl -L | bash -s stable --ruby

Note: run the source command outputted from the above command

$ rvm install 1.9.3
$ rvm use 1.9.3
$ rvm --default 1.9.3

The above commands install RVM, install ruby version 1.9.3, tell RVM to use the 1.9.3 version for the rest of the stuff you’ll install and set 1.9.3 to be default going forward.

Install XQuartz

NOTE: This step is optional and is only necessary if you plan to do image manipulation using ImageMagick.

Apple no longer ships an X Windowing system starting with Mountain Lion, so you’ll probably need to install the open sourced version of this available at

Install Rails

$ gem install rails

Rails should now be installed. To create a test app, run

$ rails new my_app_name

If you get an error about OpenSSL support, you may need to update RVM. See the instructions at

Optional: MySQL
MySQL is a popular open source database that you may want to install locally to make sure that it behaves the same as your production instance of MySQL (if that’s what you’re running). Rails abstracts a lot of the different database differences to your app, but you still may want to actually run MySQL just to have the added confidence that there aren’t any subtle quirks/differences.

$ brew install mysql

 $ unset TMPDIR

 $ mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

 $ mysql.server start

 $ /usr/local/opt/mysql/bin/mysqladmin -u root password '[[[YOUR_ROOT_PASSWORD_HERE]]'

If you want to have MySQL start automatically when your Mac logs in, you can set it up like this:

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

Optional: ImageMagick

  • I had to do some basic image manipulation in my app (resizing photos, etc) and I had to install the ImageMagick package through homebrew to get it working.
$ brew uninstall imagemagick
 $ brew install --fresh imagemagick

Done! I had to try a lot of combinations to get it working on my laptop and my app; hopefully this helps as most of the online resources I found were out of date for Mountain Lion or the newest version of XCode.

There are also more detailed instructions for the Mac, as well as Linux installation instructions available at

Happy coding!

Rack Blogger is our catchall blog byline, subbed in when a Racker author moves on, or used when we publish a guest post. You can email Rack Blogger at


  1. Once I have installed Command Line Tools, how do I install homebrew?
    Where do I put in those commands?

    • You should write those commands in Mac OS Terminal. Applications > Utilities > Terminal. be sure that you are in root!

  2. This is awesome! Just got a new computer and didn’t have to demolish the internet to find every little detail.

    I did have one issue…

    When installing RVM: ‘curl -L | bash -s stable –ruby’ I had to add and extra dash to ruby: ‘ –ruby’

  3. I kept having problems getting rails to install. Turning off Avast anti virus solved the issue.

    Good tutorial the steps were easy to follow once I figured out I needed to disable anti virus

  4. help please!!!
    i have a problem with step : install RMV
    there is error:
    ruby-2.0.0-p247 – #configuring……..
    Error running ‘./configure –prefix=/Users/angelina/.rvm/rubies/ruby-2.0.0-p247 –disable-install-doc –without-tcl –without-tk –enable-shared’,

    • I’ve also hit the asme problem. Looking up change.log, I found this –

      checking whether the C compiler works… no
      configure: error: in `/Users/joy/.rvm/src/ruby-2.0.0-p247′:
      configure: error: C compiler cannot create executables

      Now, I had installed the apple gcc using brew And it installed without any issue. So, to cross check, I wrote a Hello World C program and tried compiling it.


      int main()
      printf(“Hello Worldn”);
      return 0;

      test.c:1:19: error: stdio.h: No such file or directory
      test.c: In function ‘main’:
      test.c:5: warning: incompatible implicit declaration of built-in function ‘printf’

      My assumption is something went wrong with the header file locations with the new gcc installation.

      Also, I had previously installed gcc via XCode Developer tools. Does this have to do something with this?

  5. Thanks for the tutorial. Very helpful. Even to someone who has only owned a Mac for 4 hours 🙂

    If you use SU at any point during your install, make sure that you are not root or SUDO when installing gems. You will run into a lot of permission issues if you install gems at root.

  6. Excellent writeup thanks. Had to reinstall OSX twice before i came across this and now i have my rails environment perfectly set up.

  7. Thank you very much for your article. I’m a Rube-Newb, but wanted to note for Mac users that homebrew IS ideal for configuring Ruby, but you can still use macports alongside homebrew if you trunk macports in /opt/. Declaring $ rvm autolibs homebrew should default Ruby dependencies to be checked against homebrew instead of macports (which is the default). So my request, since you pushed me over into Ruby zone today, is for you to write an article about trunking and having macports and homebrew on one machine 😀

  8. Thank you so much I have followed so many tutorials to get rails going and yours….. finally worked for me! you are a lifesaver!!!

  9. Hi, I’m very new to this, and so far you’ve helped me a lot!

    I’m not sure at all, but should I change the rvm commands into Ruby version 2.0.0-p247? ( version since the the article got published?)
    Or is it on purpose that the version used in the article is a previous version?

    I’ve run the rvm commands with the version from this article, but if I “should” use Ruby 2.0.0-p247, how do I change that? Or is it actually no matter really?

    And again, this helped me a lot – thanks! 🙂

  10. Installation of ruby on rails on Mac is quite different as compare to windows. You will require a proper assistant to get it install. Ruby on Rails is an open source full-stack web application framework written in Ruby. It follows the popular MVC framework model and is known for its “convention over configuration” approach to application development. Ruby on Rails development is a full-stack web framework optimized for programmer happiness and sustainable productivity.

  11. What is “rails” and why would I want to install it?

    (Yeah, I know it is a dumb question, but it is a dumb question that SHOULD have been answered by the article…)

    Don’t bother with a reply, I am off to google it…


Please enter your comment!
Please enter your name here