Installing JRuby on My MacBook Pro

JRuby

After talking to my soon-to-be manager on Monday, I learned that the initial code they are building is in JRuby, as there's a ton of Ruby code in The Shop, and yet JRuby allows you to drop down into the JVM should performance be an issue. I know next to nothing about Ruby or JRuby, so it made sense to install JRuby and see what's up. Turns out, it was pretty simple, if they had the installer package working a little better.

The first thing was to get the disk image from the JRuby site. There are several ways to download it, and I picked the dog as it had installers and uninstallers - should that prove to be necessary. In any case, it installed fine, but I could not find the jruby executable.

I looked in the installer's package contents, and it turns out that the entire thing is a simple Framework, and everything can point to a simple path and we're good to go. This process took me a few minutes, and could have been cleared up with a simple README in the disk image, but hey, what's a few minutes between friends?

In order to get the path correct, I took advantage of the /user/libexec/path_helper script and placed into /etc/paths.d/ the file jruby that looks like:

  /Library/Frameworks/JRuby.framework/Versions/Current/bin

and on the next shell start, we'll pick this up in the path. Now if the JRuby guys are smart, they will have been careful to make sure that when they call commands like irb, they are doing it within the Framework directory. And here's why…

The install script added a few lines to my .tcshrc, but it added Bash script. Easy fix, but they put the JRuby path at the end of the PATH. This means that when I use the /usr/libexec/path_helper to add in the JRuby path, I get:

  peabody{drbob}7: echo $PATH
  /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:
  /Library/Frameworks/JRuby.framework/Versions/Current/bin:.:/Users/drbob/bin:
  /usr/local/qt/bin:/usr/local/xerces/bin:/usr/local/groovy/bin

and we can see that the path for JRuby is after /usr/bin where the Mac OS X install of rib is located. I'm going to leave it like this for a while in the hopes that they did it right (I would have), and I won't have to force the path addition to the front of the PATH. We'll see.

At this time, we can now check that JRuby is successfully installed:

  $ jruby -v
  jruby 1.7.0.preview1 (ruby-1.9.3-p203) (2012-05-19 00c8c98)
  (Java HotSpot(TM) 64-Bit Server VM 1.6.0_33) [darwin-x86_64-java]

Good enough. Now I need to start reading up on JRuby and see what I can see. It's going to be exciting!