Friday, February 26, 2010

Installing Ruby 1.9.1 with Ruby Version Manager (RVM) on Mac OS X Snow Leopard

For some reason, Ruby 1.9.1 didn't install on my Mac OS X Snow Leopard because of an error:

Error running 'make ', please check /Users/home_dir/.rvm/log/ruby-1.9.1-p378/make*.log

The error in ~/.rvm/log/ruby-1.9.1-p378/make*.log:

compiling readline

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

So compiling Ruby 1.9.1 with the default readline installed on Snow Leopard didn't work.

By looking at "rvm --help" or ~/.rvm/README, there is an option to specify custom configure options, i.e. -C|--configure. Also there is a flag to force ./configure on install even if Makefile already exists, i.e. --reconfigure.

So I installed readline with MacPorts and installed Ruby 1.9.1 with the option and the flag:

$ sudo port install readline

$ rvm install 1.9.1 --reconfigure --configure --with-readline-dir=/opt/local

Then installation succeeded.