Debugging in ruby 1.9

Viewed 29198

What do you guys use for debugging in ruby 1.9? rdebug doesn't seem to be compatible.. is there anything out there?

12 Answers

Note: this answer was correct but is now out of date. See the below correct answer. TL;DR: use 'debugger' now.

ruby-debug is now available with Ruby 1.9.x. See http://www.github.com/mark-moseley

To install (using gem on 1.9 Ruby installation):

gem install ruby-debug19

(with perhaps the necessary 'sudo' in front of it).

Some things you could try

1) run it with ruby’s normal debugger -rdebug [1] kind of slow

2) run it with unroller gem [kind of stinks, way slow]

3) use a lot of print statements fast, kind of less introspection possible

4) drop to an irb prompt and run some code from there.

you could list the code by creating your own “drop to irb prompt” that listed the code around itself [use caller to discover where you where] then drop to a normal irb prompt.

5) maybe jruby in 1.9 compat mode has a debugger?

[1] http://beaver.net/rdebug/index-0.html

Netbeans is a good IDE for RoR. Good debugger too.

There is a lot of choices, depending on your needs.

I use pry-moves because I can "look back" into what happened inside of previous command by re-executing them in debug mode right from the place.

Related