How to debug Ruby scripts

Andrew Grimm picture Andrew Grimm · Oct 18, 2010 · Viewed 164.1k times · Source

I copied the following Ruby code from the Internet and made a few changes but it doesn't work.

What can I do to debug the program by myself?

Answer

horseyguy picture horseyguy · Nov 3, 2011

Use Pry (GitHub).

Install via:

$ gem install pry
$ pry

Then add:

require 'pry'; binding.pry

into your program.

As of pry 0.12.2 however, there are no navigation commands such as next, break, etc. Some other gems additionally provide this, see for example pry-byedebug.