Compile Ruby 1.9.2 with RVM using Homebrew installed Iconv

Iconv

I spent a very frustrating hour this morning trying to get the JSON gem to work on Ruby 1.9.2 p136 installed via RVM on Snow Leopard. I thought I would post my solution to help any other unfortunate souls.

The RVM docs suggest installing a sandboxed version of Iconv like so:

$ rvm package install iconv

This didn't work. I got archictecture errors during compile. I then tried to install the iconv gem, which again didn't work. It couldn't seem to find the iconv lib files.

In the end, I installed icon with Homebrew and linked it to Ruby like so:

$ brew install libiconv
$ rvm remove 1.9.2
$ rvm install 1.9.2 --with-iconv-dir=/usr/local/Cellar/libiconv/1.13.1

This compiled Ruby with the Homebrew installed iconv libraries and the json gem worked just fine after.

Comments