Debugging JRuby apps

Let me start off by saying that I love using vim and textmate for hacking sessions, however, when it comes to getting into the nitty gritty details of a running program to figure out what’s going on, it’s nice to have a debugger.

The ruby-debug gem does not work in jruby directly, as it depends on native APIs.
There is a Java-based JRuby implementation of the fast ruby debugger rdebug.

One of my favorite editors is IntelliJ IDEA, and now that it has a Ruby plugin, it’s even better. IDEA allows you to easily navigate classes, and it does a pretty good job with a dynamic language like jruby. One of the best parts about IDEA is being able to visually debug a jruby gem or jruby on rails application directly in the IDE, so that you can step in, over or though method calls, examine variables, evaluate expressions, etc.

In order to get your jruby installation set up correctly, however, there are a few simple steps you need to take first.

1. Manually download the ruby-debug-base-0.10.3-java.gem from debug-commons.

sudo jruby -S gem install ruby-debug-base-0.10.3-java.gem

2. Leave the directory and then do the following:

sudo jruby -S gem install –-ignore-dependencies ruby-debug –version 0.10.3
sudo jruby -S gem install –-ignore-dependencies ruby-debug-ide

3. Now install columnize

sudo jruby -S gem install columnize

You should be good to go. Having an excellent tool to debug your apps could boost your productivity as well.


5 responses to this post.

  1. Posted by Codey Christensen on October 20, 2009 at 11:54 pm

    Netbeans IDE supports all of this, with the fast debugger on JRuby out of the box. It does an incredible job with Ruby as well. Amazing debug tool, and a few less steps to be taken than IDEA. Thanks or the info on IDEA though!


  2. Posted by Chris on November 2, 2009 at 1:47 pm

    I’ve been using ruby-debug for a while, though I’ve found that after a while your output can get all messed up. Sometimes keystrokes don’t work properly, the output seems to run differently than the native ruby-debug and the only way to fix the problem is to terminate the program and start over again.

    Have you had this kind of issue too?


  3. In future JRuby 1.5 (and already on master branch) the debug gems will come with JRuby bundled by default, so there will be no need no download and install ruby-debug gems at all. Less work –> happier users. 🙂


  4. That’s really helpful, thanks. Looking forward to seeing the gems included as Vladimir described.


  5. Thanks for posting this very helpful information; I happened to come to your blog just searching around the web. Please keep up the good work!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: