2

I am trying to install Ruby on my new Mac, but I'm having some issues, and was wondering if anyone can help?

The main error is:

Right now Ruby requires gcc to compile, but Xcode 4.2 and later no longer ship with gcc.
Instead they ship with llvm-gcc (to which gcc is a symlink) and clang, neither of which are
supported for building Ruby. Xcode 4.1 was the last version to ship gcc, which was
/usr/bin/gcc-4.2.

I tried to solve the error using the advice in this post "Cannot install ruby-1.9.2 in Mac OSX 10.8.1 due to symlink error", but even after installing gcc via homebrew, I still get the aforementioned error.

When I type gcc - v, I get the following message:

Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~67/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~67/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)

Lastly, I checked my /usr/bin folder, and I see a gcc-4.2 unix executable file that is about 104KB. Is this what I should have?

Community
  • 1
  • 1
Dan Tang
  • 1,273
  • 2
  • 20
  • 35

3 Answers3

2

Try this to let rvm know which gcc to use:

CC=/usr/bin/gcc-4.2 rvm install 1.9.3 

Or, if you want to use the Homebrew-installed gcc:

CC=/usr/local/bin/gcc-4.2 rvm install 1.9.3

It depends on where the gcc-4.2 interpreter is.

Two alternatives:

rvm install 1.9.3 --with-gcc=clang

Or use ruby-build.

EDIT September 7, 2013: Another alternative that I'm liking quite a lot for installing Rubies is ruby-install. It's in the spirit of the same author's chruby. Simple and gets the job done well.

Telemachus
  • 19,459
  • 7
  • 57
  • 79
1

I do not have the reputation yet to make a comment but i just wanted to note that based on Telemachus comment this worked for me rvm install 1.9.3 --with-gcc=clang

im running os x 10.8.4

todd
  • 322
  • 1
  • 4
  • 9
0

you should install xcode command line tool first, you can find in xcode preferences' download tab.

enter image description here

then install homebrew, it's a package manager like yum in centos, you can use that to install git etc.

then install rvm, then use rvm install ruby.

Xiujun Ma
  • 2,574
  • 1
  • 14
  • 19
megayu
  • 161
  • 5
  • He was able to install `gcc` with Homebrew. I'm pretty sure he has the Command Line Tools - otherwise, that wouldn't have been possible. – Telemachus Dec 27 '12 at 22:49