How to install ruby-debug19 on Windows and debug in NetBeans

Working with Ruby on Rails on a Windows machine can be painful at times. Especially installing the ruby-debug19 gem and getting it to work properly can be a challenge. In the following I will try to show you how to overcome known problems during the installation process.
I assume that you have already installed a working Ruby 1.9.x version. If not, you may want to download the newest version of ruby and follow the given instructions.
First of all, try to install ruby-debug19 with the following command inside your command shell:

gem install ruby-debug19 ruby-debug-ide19

If this worked for you: Great! But most likely it didn’t work and you got some error message similar to the following:

Building native extensions. This could take a while...
ERROR: Error installing ruby-debug19:
ERROR: Failed to build gem native extension.

If this is the case, you need to install the Ruby Development Kit. You can get the DevKit here. Then go ahead and extract the contents to any folder you like. Navigate to that folder inside your command shell and execute the following commands:

ruby dk.rb init
ruby dk.rb install

Now the Ruby DevKit should be properly installed already. If you experienced any problems during installation please take a look at this detailed installation and troubleshooting guide.
Now execute the “gem install” command from above once again. If everything has been set up correctly you should be able to properly install ruby-debug19 and see something like this:

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Successfully installed ruby-debug-base19-0.11.25
Successfully installed ruby-debug-19-0.11.6
Successfully installed ruby-debug-ide19-0.4.12
3 gems installed

By installing the ruby-debug-ide19 gem you should be able to debug your project inside your IDE. However, trying to debug a Ruby on Rails project in NetBeans sometimes needs manual patching. You might experience an error quite similar to this one when launching the debugger:

Fast Debugger (ruby-debug-ide 0.4.9) listens on :50405
        C:/Ruby192/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug-ide.rb:123:in `debug_load'
        C:/Ruby192/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug-ide.rb:123:in `debug_program'
        C:/Ruby192/lib/ruby/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/bin/rdebug-ide:87:in `'
        C:/Ruby192/bin/rdebug-ide:19:in `load'
        C:/Ruby192/bin/rdebug-ide:19:in `'
Uncaught exception: no such file to load -- script\rails

This seems to be a bug inside ruby-debug-ide19 where execution paths are not set correctly. You can hotfix this problem by editing line 123 in ruby-debug-ide.rb (the line that throws the error). Replace the line

bt = debug_load(Debugger::PROG_SCRIPT, options.stop, options.load_mode)


bt = debug_load('./script/rails', options.stop, options.load_mode)

Restart the debugger and you should be able to debug your projects inside NetBeans.

Please vote: How useful was this post for you?
Current rating:
(3 out of 5)
This entry was posted in Ruby on Rails and tagged , , , . Bookmark the permalink.