Here’s how you can setup debugging with your Ruby environment using Netbeans 6.1. Netbeans 6.1 comes with a debugger installed, but only with JRuby, this is how to set it up to work with Ruby.

Due to a bug with Netbeans 6.1 you must have the following versions of gems installed:

  • ruby-debug-ide 0.1.10
  • ruby-debug-base 0.10.0

This bug will be resolved in Netbeans 6.5, to allow support for newer versions of the gems.

Install the required gems

Install the two gems via gem command:

gem install ruby-debug-ide -v 0.1.10
gem install ruby-debug-base -v 0.10.0

If you need to uninstall newer versions of the gems, you can uninstall by:

gem uninstall ruby-debug-ide -v 0.2.0
gem uninstall ruby-debug-base -v 0.10.1

Once installed, when you open up Netbeans goto, Tools -> Ruby Platforms in the menu and select click Autodetect Platforms. Your screen should look similar to this: (Note: MacOSX setup)

Inserting a Break Point

You can insert break points in your Ruby code and in your views. You can simply add one by clicking the line number on the left side of the line of code you wish the debugger to stop.

Debug Your File

Simply right-click your code and select Debug “<filename>”.

Your default browser should attempt to load the page, and if you go back into Netbeans you can see information about the break point and the current local variables at the break point.

Debug Toolbar

You have access to your normal debug functions such as Step In/Out, Continue etc, via the Netbeans Debug toolbar.