When Trouble Strikes(Chapter 14 of Programming Ruby)
Ruby comes with a debugger, which is conveniently built into the base system. You can run the debugger by invoking the interpreter with the -r debug option, along with any other Ruby options and the name of your script: ruby r debug [ debug-options ] [ programfile ] [ program-arguments ] .