Skip to content

UsingTheJRubyDebugger

Douglas Campos edited this page Jun 7, 2011 · 4 revisions

There is a Java-based JRuby implementation of the fast ruby debugger rdebug.

See: JRuby Fast Debugger

Note that more recent versions of jruby (1.5+) already include the gem pre-bundled, so a

require 'rubygems'
require 'ruby-debug'
debugger

is probably all you'll need.

If you're running an older version of jruby then you'll need to follow these instructions:

  • Manually download the most recent ruby-debug-base-0.10.3.x-java.gem from [http://rubyforge.org/frs/?group_id=3085 debug-commons].
  • Install the Gem into your JRuby Gem repository:
jruby -S gem install ruby-debug-base-0.10.3.2-java.gem
  • Leave the directory or remove ruby-debug-base-0.10.3.2-java.gem from the directory and install ruby-debug with:
jruby -S gem install --ignore-dependencies ruby-debug
jruby -S gem install --ignore-dependencies ruby-debug-ide # needed only for IDEs
  • Install the columnize gem (unless you already have):
jruby -S gem install columnize

Note: the --debug option used below works only with JRuby 1.1.3 and later. For older versions you need to stick with the old option, using -J-Djruby.reflection=true -J-Djruby.compile.mode=OFF instead --debug.

Starting the debugger on a Rails application:

cd my_rails_app
jruby --debug -S rdebug script/server

Starting the debugger to test a local ruby program and adding ''lib/'' to the load path:

ruby --debug -S rdebug -Ilib rubyprogram.rb 

or you can call it programmatically within the script

require 'ruby-debug'
debugger

just make sure to run it under a jruby with the --debug flags passed to it, or "next" will always act as if it were the "step" command.

External Resources:

Clone this wiki locally