rbenv fails to install ruby 1.8.7 on MacOS X Sierra

Viewed 1206

After creating a .ruby-version file with 1.8.7, running rbenv install on the same directory where the file is gives the following error:

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 to llvm-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 with llvm-gcc. To build older versions of Ruby you must have the official GCC compiler installed on your system.

TO FIX THE PROBLEM: Install Homebrew's apple-gcc42 package with this command: brew tap homebrew/dupes ; brew install apple-gcc42

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.

BUILD FAILED (OS X 10.12.4 using ruby-build 20170405-2-g3b15693)

Then running brew install apple-gcc42 gives:

apple-gcc42: This formula either does not compile or function as expected on macOS versions newer than Mavericks due to an upstream incompatibility. Error: An unsatisfied requirement failed this build.

Stuck trying to install ruby 1.8.7 through rbenv on MacOS X Sierra. Any ideas on how to fix this?

2 Answers
Related