Rails debugging triggers an internal error message

Posted by ericp on 2009-09-21 08:49
OS: All / Any | Product: Komodo | tags: rails debugging
Question: 

When I try to debug Rails apps or unit tests in Komodo, I get an error message "INTERNAL ERROR!!! You have a nil object when you didn't expect it!" instead of breaking.

Answer: 

The problem is that a couple of Rails files are now loading ruby-debug-base whether it's requested or not. The result is that a mixture of objects in the Debugging module are loaded, and they conflict.

I submitted a patch at https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/2895 requesting that Rails loads the debugging environment only if it hasn't been loaded yet. I don't know if the patch has been applied to trunk yet, but it's an easy fix:

Find the two files in either your gem or vendor area:

actionpack/test/abstract_unit.rb
railties/lib/test_help.rb

Find these lines:

begin
  Debugger.start
rescue LoadError
  # Debugging disabled. `gem install ruby-debug` to enable.
end

and change the 'end' to

end unless defined? Debugger