Skip to content

Installing the rjb gem

I’ve decided to give JRuby a try under Mac OS X 10.5.5, and the ride has had its share of challenges so far. First thing, after I downloaded and extracted JRuby to a folder in my machine, I had to setup the JRUBY environment variable, and make a change to the PATH variable, that looked like this:

export JRUBY_HOME=/Users/junior/code/jruby/jruby-1.1.5
export PATH=$JRUBY_HOME/bin:$PATH

Pretty simple so far, but I was getting errors trying to install the Ruby Java Bridge gem. To my surprise the reason was that I was running the gem executable from JRuby, not my regular gem executable, as I expected. The fix was simple, I just had to change the path variable to look like:

export PATH=$PATH:$JRUBY_HOME/bin

Then, I spent almost one hour trying to find out why the rjb gem wouldn’t install in my machine. I found lots of blog post from people who had issues installing this gem, and presented a few solutions, but none helped me. I kept getting an error saying that the JAVA_HOME variable was not set, which made no sense because this was working fine:

junior@snake:~$ export JAVA_HOME=/Library/Java/Home
junior@snake:~$ $JAVA_HOME/bin/java -version
java version "1.5.0_16"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-284)
Java HotSpot(TM) Client VM (build 1.5.0_16-133, mixed mode, sharing)

I got the answers to my problem online from a blog post by Alex Chaffee. Like Alex mentioned, just run “sudo visudo” and add

Defaults        env_keep += "JAVA_HOME"

Pretty frustrating, but now I can jump back into my original task, which is to generate PDF reports from a Rails application using the iText Java library.