How can I install Ruby 1.9.3 in Mac OS X Lion?

I am trying to install Ruby 1.9.3 but am having problems. I installed RVM, then typed:

rvm install 1.9.3

The output says:

ERROR: Error running ' ./configure....

The log says:

configure: WARNING: unrecognized options: --with-libyaml-dir 
checking build system type... x86_64-apple-darwin11.2.0 
checking host system type... x86_64-apple-darwin11.2.0 
checking target system type...x86_64-apple-darwin11.2.0 
checking whether the C compiler works... no
configure: error: in `/Users/myuser/.rvm/src/ruby-1.9.3-p0':
configure: error: C compiler cannot create executables See `config.log' for more details

I downloaded the new XCode from the App Store and installed it.


Try using the clang compiler instead of the default:

rvm install 1.9.3 --with-gcc=clang

RVM needs gcc-4.2 to be able to install ruby 1.9.3. Unfortunately Lion does not include anymore gcc-4-2, just the llvm version:

lrwxr-xr-x  1 root  wheel  12 15 feb 17:21 /usr/bin/gcc -> llvm-gcc-4.2

If you have Lion but upgraded from Snow Leopard it is likely that you still have gcc-4.2 If you have a brand new installation of Lion you should download gcc-4.2. I recommned downloading this package.

https://github.com/kennethreitz/osx-gcc-installer

Check that you have gcc-4.2 installed now:

-rwxr-xr-x  1 root  wheel  113024 16 may  2011 /usr/bin/gcc-4.2
lrwxr-xr-x  1 root  wheel      12 15 feb 17:21 /usr/bin/gcc -> llvm-gcc-4.2

Now you can install ruby 1.9.3 as usual:

rvm install 1.9.3
rvm use 1.9.3 --default