Skip to content

Instantly share code, notes, and snippets.

@kapoorlakshya
Last active June 7, 2019 23:06
Show Gist options
  • Save kapoorlakshya/911ff9cdf711de40dea5d51927e92d5c to your computer and use it in GitHub Desktop.
Save kapoorlakshya/911ff9cdf711de40dea5d51927e92d5c to your computer and use it in GitHub Desktop.
Debugging in JRuby 9.2.x

Debugging in JRuby 9.2.x

  1. Add these gems in gemfile or gemspec:
gem 'ruby-debug'
gem 'columnize'
  1. Add require 'ruby-debug' in your project.
  2. Add breakpoints with debugger keyword.
  3. Run jruby with --debug flag:
jruby --debug -S bundle exec <command>

Create ~/.rdebugrc

Unlike pry or byebug where we can simply call the variable to see its value, we have to use p to print the value. For example, my_var vs p my_var. We can change this behavior to autoeval by adding the following lines to a ~/.rdebugrc file:

set autolist
set autoeval
set autoreload

SimpleCov

SimpleCov does not work with ruby-debug. Temporarily uncomment it from your MRI based while it runs on JRuby. See ruby-debug/ruby-debug#27 for more information.

Sources

https://github.com/jruby/jruby/wiki/UsingTheJRubyDebugger https://gist.github.com/klappradla/69029a982ade44e20e124c29b1c00541

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment