· ruby

Installing Ruby 1.9.2 with RVM on Snow Leopard

Yesterday evening I decided to try and upgrade the Ruby installation on my Mac from 1.8.7 to 1.9.2 and went on the yak shaving mission which is doing just that.

22883042 01f3a1a3d2

RVM seems to be the way to install Ruby these days so I started off by installing that with the following command from the terminal:

bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )

That bit worked fine for me but there are further instructions on the RVM website if that doesn’t work.

Unfortunately my first attempt…​

rvm install 1.9.2

…​resulted in the following error in the log file:

yaml.h is missing. Please install libyaml.
readline.c: In function ‘username_completion_proc_call’:
readline.c:1292: error: ‘username_completion_function’ undeclared (first use in this function)
readline.c:1292: error: (Each undeclared identifier is reported only once
readline.c:1292: error: for each function it appears in.)
make[1]: *** [readline.o] Error 1
make: *** [mkmain.sh] Error 1

I thought that perhaps 'libyaml' was the problem but Michael Guterl pointed me to a post on the RVM mailing list which suggests this was a red herring and that the real problem was 'readline'.

I tried that and then ran the following command as suggested on Mark Turner’s blog post:

rvm install 1.9.2-head -C --enable-shared,--with-readline-dir=/opt/local,--build=x86_64-apple-darwin10

That resulted in this error:

ld: in /usr/local/lib/libxml2.2.dylib, file was built for i386 which is not the architecture being linked (x86_64)
collect2: ld returned 1 exit status
make[1]: *** [../../.ext/x86_64-darwin10/tcltklib.bundle] Error 1
make: *** [mkmain.sh] Error 1

Michael pointed out that I needed to recompile 'libxml2.2' to run on a 64 bit O/S as I’m running Snow Leopard.

I hadn’t previously used the 'file' function which allows you to see which architecture a file has been compiled for.

e.g.

file /usr/local/lib/libxml2.2.dylib

/usr/local/lib/libxml2.2.dylib: Mach-O dynamically linked shared library i386

I had to recompile 'libxml2.2' to run on a 64 bit O/S which I did by downloading the distribution from the xmlsoft website and then running the following commands:

tar xzvf libxml2-2.7.3.tar.gz
cd libxml2-2.7.3
./configure --with-python=/System/Library/Frameworks/Python.framework/Versions/2.3/
make
sudo make install

Re-running RVM Ruby installation command I then had this error instead:

tcltklib.c:9539: warning: implicit conversion shortens 64-bit value into a 32-bit value
ld: in /usr/local/lib/libsqlite3.dylib, file was built for i386 which is not the architecture being linked (x86_64)
collect2: ld returned 1 exit status
make[1]: *** [../../.ext/x86_64-darwin10/tcltklib.bundle] Error 1
make: *** [mkmain.sh] Error 1

I downloaded the sqlite3 distribution and having untarred the file ran the following commands as detailed on this post:

CFLAGS='-arch i686 -arch x86_64' LDFLAGS='-arch i686 -arch x86_64'
./configure --disable-dependency-tracking
make
sudo make install

Next I needed to recompiled 'libxslt' which I downloaded from the xmlsoft website as well before untarring it and running the following:

./configure
make
sudo make install

Having done that I re-ran the RVM Ruby installation command:

rvm install 1.9.2-head -C --enable-shared,--with-readline-dir=/opt/local,--build=x86_64-apple-darwin10

And it finally worked!

The magnificent yak is borrowed under the Creative Commons Licence from LiminalMike’s Flickr Stream.

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket