This is step 4 of Installing Ruby on a Mac and covers Ruby version 1.9.2 and 1.9.3.
Getting Started
Step 1 - Xcode, Homebrew and Git
Step 2 - Wget and OH MY ZSHELL
Step 3 - RVM
_Step 4 – Ruby_
Step 5 - Gems and Pow
Step 6 – Databases and Rails
Hello World
As previously mentioned OS X Lion comes pre-loaded with an older version of Ruby but with RVM installing new Ruby interpreters is fairly trivial.
First, version 1.9.2. Open a terminal session and run RVM:
RVM has to download and compile Ruby on your machine so this might take a relatively long time… be patient.
If you’ve followed all the previous steps to the letter, this should have gone smoothly. Let’s switch to the new version:
$ rvm use 1.9.2 --default
Check the change:
Output:
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.2.0]
At the time of writing, a 1.9.3 version had been released so I decided to install it as well:
However this time I got an error:
Installing Ruby from source to: /Users/pascal/.rvm/rubies/ruby-1.9.3-p0, this may take a while depending on your cpu(s)...
ruby-1.9.3-p0 - #fetching
ruby-1.9.3-p0 - #extracted to /Users/pascal/.rvm/src/ruby-1.9.3-p0 (already extracted)
Fetching yaml-0.1.4.tar.gz to /Users/pascal/.rvm/archives
Extracting yaml-0.1.4.tar.gz to /Users/pascal/.rvm/src
Configuring yaml in /Users/pascal/.rvm/src/yaml-0.1.4.
Compiling yaml in /Users/pascal/.rvm/src/yaml-0.1.4.
Installing yaml to /Users/pascal/.rvm/usr
ruby-1.9.3-p0 - #configuring
ERROR: Error running ' ./configure --prefix=/Users/pascal/.rvm/rubies/ruby-1.9.3-p0 --enable-shared --disable-install-doc --with-libyaml-dir=/Users/pascal/.rvm/usr ', please read /Users/pascal/.rvm/log/ruby-1.9.3-p0/configure.log
ERROR: There has been an error while running configure. Halting the installation.
After a bit of googling, I discovered that quite a few others have had a similar problem. Fortunately StackOverflow (and RVM) came to the rescue with an answer which worked for me:
$ rvm install 1.9.3 --with-gcc=clang
But what on earth is --with-gcc=clang you may ask?
If I’m not mistaken it’s just a flag that tells RVM to use the Clang compiler to build Ruby.
From Wikipedia Clang is:
“A compiler front end for the C, C++, Objective-C, and Objective-C++ programming languages. It uses the Low Level Virtual Machine (LLVM) as its back end, and Clang has been part of LLVM releases since LLVM 2.6. Its goal is to offer a replacement to the GNU Compiler Collection (GCC). Development is sponsored by Apple.”
There you are :)
To check which version of Clang is on your system:
Output:
Apple clang version 3.0 (tags/Apple/clang-211.10.1) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin11.2.0
Thread model: posix
And GCC:
Output:
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Now that we’ve got 1.9.3 compiling, let’s set it as the default environment:
$ rvm use 1.9.3 --default
Here’s a screenshot from JewelryBox showing detailed information of the current Ruby environment on my machine:

If you are satisfied that everything is working on your machine, proceed to step 5…
If you see any inaccuracies, things that should be added, removed or corrected, please either leave a comment or drop me an email. Thanks.