The Ruby Debugger
Debuggers can also be quite powerful, and Ruby 3.1 came with a big improvement to Ruby’s standard debugger. The new debugger is distributed as a separate Ruby gem rather than part of the standard library:
| $ gem install debug |
Note that the gem is named debug and not debugger. The debugger gem is a separate tool that hasn’t been maintained since 2015. Similarly, if you’re using Bundler, specify a version constraint of ">= 1.0.0" or else you’ll get a different, older gem. Global, permanent namespaces are fun!
After you have installed the debugger gem, there are a few different ways to start the debugger.
You can start your script with the command rdbg rather than ruby:
rdbg code/trouble/profileeg.rb
The script ...
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.