Pry

In addition to the official Ruby debugger and the official irb client, there is a third-party alternative called Pry.[29]. Pry predates the Ruby 3.1 debugger and contains many overlapping features, but with a slightly different command-line interface.

To install Pry, you need the Pry gem. Pry also has a plugin system that allows extensions, and we’ll be adding the pry-byebug gem that gives step-by-step debugging control to Pry. You can add them to a Gemfile:

 gem ​"pry"
 gem ​"pry-byebug"

The main way to use Pry is by adding the method call binding.pry into a code base. If we do that with the same code we used for the debugger earlier, just by replacing require "debug" with require "pry" and the binding.break call with binding.pry we ...

Get Programming Ruby 3.3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.