In BlogPost, Rails, Ruby

Troubleshooting By Example: Installing Derailed Benchmarks With Sinatra

So recently I was helping someone troubleshoot installing the derailed_benchmarks gem. Basically this gem, profiles your Ruby applications and helps you run benchmarks against your Rails applications.

software engineering

You can actually see me make comments on the troubleshooting thread on GitHub here.

Working with other newer developers (and recalling being one myself), I realized the key to successful debugging is the following framework I’ve always followed.

To help illustrate this, I’m going to use the aforementioned GitHub thread as a case study. I think troubleshooting by example will help illustrate this process the best.

Step 1 – Read the error message

The first step is to read the error message. The original comment is here and I’m republishing an abbreviated version for reader convenience:

Right away, I see that for some reason the rack/test file can’t be loaded for some reason.

Step 2 – Recreate the same conditions that produced the error message

The next step is trying to recreate the conditions that produced the error message. I’m hopeful that the person who posted the question has a repository all setup that can help me reproduce the error.

So I ask the poster of the question if he does, and he says:

@treble37 unfortunately, I don’t – it’s closed source. I could make a little Sinatra app that demonstrates the problem, if that would help, but I’m honestly just following the Sinatra docs as far as creating modular Sinatra apps.

Dang, he doesn’t. So that means I have to make my own small Sinatra application to recreate the problem.

So I did over here on GitHub.

Step 3 – Create a hypothesis

After recreating the poster’s original error, I created a hypothesis. I guessed that he needed to install rack-test.

Step 4 – Test the hypothesis

So then I decided to test the hypothesis. I added rack-test to the Gemfile of my repository and tried it out.

It happened to work and here is my answer to the original poster:

@nicatronTg, looking at your error about LoadError: cannot load such file – rack/test – I think you have to install rack-test.

Here is a link to the tiny repo I made that shows one possible setup: https://github.com/treble37/sinatra_with_derailed_example/blob/master/Gemfile#L4

Step 5 – Rinse and repeat!

This ended up working according to the poster.

@treble37 I think that example is an excellent resource. While missing rack-test was probably part of it, defining DERAILED_APP as just the app name (without the run!) directive was probably part of it too.
I’ll re-open the issue if I encounter any other weird spots, but thank you! I’m now happily (or unhappily?) debugging a memory leak in a Sinatra app!
Thank you again!!

If this hadn’t worked, I would have gone back to Step 1 and read over any new errors and started the whole process over again.

Summary

Basic troubleshooting and debugging can be boiled down to 5 basic steps.

  1. Here is the link to the original thread that formed the basis for this case study.
  2. Here is my own Sinatra application I made to recreate the issue over here on GitHub.
Recent Posts