I'm familiarizing myself with some JRuby code, and I'd like to be able to place a breakpoint in the code and run (as usual) from the command-line, having it break into the debugger when it gets to that point. Is there something I can put in my code to force JRuby to break into the debugger?
I've tried running jruby -r debug foo.rb
(instead of the usual jruby foo.rb
), and then setting a breakpoint with b bar.py:98
, and then continuing. But the debugger stops every time there's an exception, and there seem to be a lot of them before it gets to the line of code I'm interested in. I'd like to be able to put the "break-into-debugger" line(s) in my code and run jruby foo.rb
and have the first place the debugger stops be at that line.
(i.e. I'm looking for the Ruby/JRuby equivalent of import pdb;pdb.set_trace()
in Python.)
You could try Netbeans Ruby IDE, it has JRuby interpreter and debugging tools embedded and you can debug visually in the IDE directly.
If using an IDE is not an option for you, just install de debug
gem into your JRuby distro and use it via debugger
command:
jruby -S gem install -l ruby-debug-base-0.10.3.1-java.gem
jruby -S gem install --ignore-dependencies ruby-debug
The debugger
command should work now.
# test.rb
require 'rubygems'
require 'ruby-debug'
debugger
# run like this:
jruby --debug -S rdebug test.rb
More information on Netbeans wiki, rdebug wiki and JRuby wiki
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With