When running rbenv install 1.9.2-p320
, I get the following output:
ERROR: This package must be compiled with GCC, but ruby-build couldn't find a suitable
gcc
executable on your system. Please install GCC and try again.DETAILS: Apple no longer includes the official GCC compiler with Xcode as of version 4.2. Instead, the
gcc
executable is a symlink tollvm-gcc
, a modified version of GCC which outputs LLVM bytecode.For most programs the
llvm-gcc
compiler works fine. However, versions of Ruby older than 1.9.3-p125 are incompatible withllvm-gcc
. To build older versions of Ruby you must have the official GCC compiler installed on your system.TO FIX THE PROBLEM: Install the official GCC compiler using these packages: https://github.com/kennethreitz/osx-gcc-installer/downloads
You will need to install the official GCC compiler to build older versions of Ruby even if you have installed Apple's Command Line Tools for Xcode package. The Command Line Tools for Xcode package only includes
llvm-gcc
.
I've got Xcode 4.3.2 installed. Am I safe to install the osx-gcc-installer over the top - will this both fix the above issue and keep Xcode running smoothly for iOS development?
Thanks in advance.
It is not generally safe to install this package over the top of Xcode. It was designed for people who want the compiler and its dependencies without having to install Xcode. If you've installed the Command Line Tools for Xcode, it will overwrite many of the files, and probably break all kinds of things.
If you only care about iOS development, you don't need the Command Line Tools for Xcode at all, so it won't matter even if they're completely broken. But in that case, you'd be better off not installing those Command Line Tools, instead of trying to install both.
A much safer alternative is to install a compiler somewhere other than /usr. You can obviously do this by building it yourself, but that's a lot of work. You may want to look into the Brew apple-gcc42 package, which is specifically designed to supplement Xcode 4.2+'s Command Line Tools by adding the missing tools (all in /usr/local/bin instead of /usr/bin, and with the suffix -4.2). Or, if you're already using MacPorts or Fink, try their packages instead. (If you need help telling different packages to use /usr/local/bin/gcc-4.2 instead of /usr/bin/gcc, etc., you should probably ask a new question.)
Another obvious alternative is to use Ruby 1.9.3, which doesn't have this problem, instead of 1.9.2. (And if you don't want to get into the hairy details of building things yourself, Brew's got a package for that, too…)