Section #2. Ruby Troubleshooting: The Usual Suspects

Even though strace, lsof, and friends are powerful tools, most of the time you should not start with them. This section is a brief recap of the techniques typically used to troubleshoot a problem with a Ruby process.

raise, puts, and debug()

Without a doubt, the most popular way to investigate an unexpected behavior in a Ruby program is to add a raise some_object.inspect statement or a puts some_object.inspect statement in the code and rerun the same test or use case. Quick and dirty...and terribly efficient (especially the raise version: It is easy to spot, and you won’t forget to remove it).

Rails has a variant for HTML rendering in a view: the debug() function. This function outputs the ...

Get Troubleshooting Ruby Processes: Leveraging System Tools when the Usual Ruby Tricks Stop Working 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.