Compiling Ruby on a fresh Lion install

During the setup of my development environment on my new iMac, I’ve run into these two issues while trying to install first Ruby (1.8.7-p352) inside rbenv:

XCode 4.2 doesn't install (non-llvm) gcc-4.2 anymore

I was getting this error:

./configure: line 3211: /usr/bin/gcc-4.2: No such file or directory

Setting the CC environment variable to use /usr/bin/gcc did fixed compiling, but Ruby was throwing segfaults.

The real fix is to install the osx-gcc-installer.

OS X provides BSD libedit, which shadows libreadline

I was getting this error:

readline.c: In function 'username_completion_proc_call':
readline.c:730: error: 'username_completion_function' undeclared (first use in this function)
readline.c:730: error: (Each undeclared identifier is reported only once
readline.c:730: error: for each function it appears in.)
make[1]: *** [readline.o] Error 1

I’ve fixed it by installing readline with brew and configuring Ruby compilation to use it:

$ brew install readline
$ CONFIGURE_OPTS="--with-readline-dir=$(brew --prefix readline)" rbenv install 1.8.7-p3
Published 2011-10-25 · Home