OSX El Capitanにrbenvで1.8.7-p375を入れる

もういい加減にしたいと思っている1.8.7なのですが、 残っているところがある以上、こちらでも開発環境を用意しなければならないのです。

rbenv install 2.2.3

とかは問題なくインストールできました。しかし、

rbenv install 1.8.7-p375

とやってみたのですが、エラーが出ます。

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.11 using ruby-build 20150818-4-g8d6ff29)

こんなエラーが出ます。エラーメッセージのとおりにやってみたのですが、 全然ダメでした。仕方ないのでビルドディレクトリに移動してみて、 ./configureをやったらあっさり通ります。 なんだ、ruby-buildの問題か。というわけで、デバッグをしはじめました。 ちょっとだけ追ってみたら、require_gccのあたりのようで、 gccのチェックをしている模様。

--- a/share/ruby-build/1.8.7-p375
+++ b/share/ruby-build/1.8.7-p375
@@ -1,3 +1,3 @@
-require_gcc
+# require_gcc

これであっさり通るようになりました。 ちゃんと直すのは面倒だなぁ。っというわけで誰かお願いします。 bashの動きを調べるのめんどい。