Debugging Using a Console Debugger

Learn to debug a program using a console debugger.

pry

We’re already familiar with pry, which is another read-execute-print-loop (REPL). pry implements more features than irb (Interactive Ruby, standard REPL). With a little bit of extra effort, we can use pry as a console debugger. Let’s look into the basics of debugging with pry. Knowing how to use this tool will save us a lot of time.

If pry is not installed on our system for any reason (we can check it with which pry), we can type a simple installation command:

$ gem install pry pry-doc

This command installs two gems: pry and pry-doc. The latter is a plugin for pry (normally, plugin names for pry start with the pry- prefix) and contains documentation about native Ruby methods.

We can type pry commands once pry is executed by just typing in our terminal, for example:

$ pry
> help

Try the above command in the following terminal.

Get hands-on with 1400+ tech skills courses.