Wednesday, October 24, 2007

Debugging a JRuby on Rails app with jruby-debug and NetBeans

We've been working on the java port of ruby-debug for awhile and it's getting perilously close to usable. And with the latest builds of NetBeans, you can actually use the NB ruby debugger with it. If you're very brave, you can try it for your yourself. Be warned, it's still a work in progress, but here's how to get started:

  1. Check out jruby from trunk and build it. You'll need java and ant, but if you're interested in jruby chances are good you have those already. It's super easy to build, check it out from http://svn.codehaus.org/jruby/trunk and do ant dist and you're good to go.
  2. Check out jruby-debug from http://debug-commons.rubyforge.org/svn/jruby-debug/trunk. In this directory, do rake install_gem. This will compile and build a jruby version ruby-debug-base, which ruby-debug (command line rdebug debugger) and ruby-debug-ide (which NetBeans and Eclipse use) both depend on.
  3. Check out ruby-debug-ide from http://debug-commons.rubyforge.org/svn/trunk/ruby-debug-ide. Then do a rake gem to build the gem and gem install pkg/ruby-debug-ide-0.1.8.gem to install it.
  4. Grab a copy of NetBeans daily builds ruby ide from here: http://deadlock.netbeans.org/hudson/job/ruby/
  5. Fire up NetBeans like with some extra command line switches: ./netbeans -J-Dorg.netbeans.modules.ruby.debugger.force.rdebug=true -J-Dorg.netbeans.modules.ruby.debugger.fast.not.required=true
    The first tells NetBeans to always use the fast debugger even tho the classic debugger is what appears selected in the UI. The second tells NB to ignore the fact that the classic debugger is selected and allow us to debug a rails app anways. These flags were just added to allow us to play with jruby-debug in NetBeans for now, they won't be necessary once jruby-debug matures a little and full support for it comes into NB.
  6. In NetBeans Tools | Options be sure and have your ruby interpreter pointing at the jruby you built from trunk in Step 1.
You should now be able to debug Ruby and ROR apps using the fast ruby debugger inside of jruby. Like I said, this is all very experimental. All these steps will go away in the next few weeks or months and jruby-debug, jruby, NetBeans, ruby-debug-ide do releases.

Things which seem to work ok:
  • setting breakpoints
  • looking at variables (global and local)
  • watches
A little flaky (tho it may already be fixed by the time you read this):
  • Stepping over some code in Rails
  • Stepping out of a method
Finally, big time kudos to Martin for kicking this whole thing off and Peter for knocking out bugs and implementing more features every hour just about. It's definitely looking close now.

15 comments:

Unknown said...

Hi, just trying to get this up and running, and cannot really get it work with NB 6.0 final. on Mac OSX Tiger platform. Can you please provide step-by step on how to actually enable ANY debugging in JRUBY. Simply none of the approaches I tried seems to work, NB always comaplin that they cannot debug JRUBY.

Thanks for advice.

Anonymous said...

I don't know if I brave enough to try it out but I will give a try. Specially that I think that it is better when everything it is build in the program. I want to finish my new program and upload it to Generic Viagra.

Buy Viagra Viagra Online

Knox Karter said...

Super-Duper site! I am loving it!! Will come back again - taking you feeds also, Thanks.
Personal Care Logo

Unknown said...

Simply none of Diablo III itemsthe approaches I tried seems to work, NB always comaplin that they cannot Buy Guild Wars 2 Golddebug JRUBY.

summerlijia said...


The legendary doomsday is around the corner, so who do you want to be together in your last minutes of life? Do not leave any regrets and enjoy yourself as much as possible. I plan to play diablo 3 games all day. Buy diablo 3 gold to do diablo 3 power leveling. Do you want to join me?

Unknown said...

Good information here. I really enjoy reading them every day. I’ve learned a lot from them.Thanks so much for sharing this information. Greatly help me being a newbie.
raspberry ketone review | raspberry ketone supplements | raspberry ketone benefits

Unknown said...

The post is written in very a good manner and it entails many useful information for me. I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement the concept.
buy raspberry ketones | where to purchase raspberry ketone | raspberry ketone reviews

Unknown said...

This member of WOW Alliance consists of guild wars 2 gold four Gnome racial traits such as Escape Artist, Expansive mind, Arcane Resistance and Engineering Specialization. These traits symbolize the Gnomes are appropriate to the roles of a Mage, Rogue but can also play as a Warrior or Warlock on www.gw2farm.com

nongfu380 said...

I all the time emailed best cheap android phones this website post page to all my contacts, for the reason that if like to readit next my links will too.

Unknown said...

Weedends is great day! I really love it! Because in this day, not only can I get up late, but also I can be relaxed!!~None day can be better than weedends! There is Günstiges android-Handy ohne Vertrag online kaufen a important reason that we can't go to school or go to job! So happy day!

Unknown said...

Hey there! This is our first stop by at your website!We are an
cheapest android phones amount of volunteers as well as starting

Unknown said...

My partner and i on a regular basis e mailed this amazing site ibaikal post site to all or any my associates, given that if prefer to readit following my personal backlinks can way too.

Unknown said...

this post. I will apt to be coming back to the websitefor cheap android phone further shortly.Piece of content will be taken to share,

nongfu380 said...

I. Require. To. Buy. This.Amazing, you might be remarkable! I like everything about it.costume cosplay vampire knight
I love all of your have missed internet connections much :) Continue the fantastic function!I like the polka dept of transportation environment. :)

Unknown said...

Really decent post I simply unearthed your weblog and wished to say that I have genuinely delighted in searching your weblog posts. Much obliged man.

Visit : Online High School Diploma