Scott's Recipes Logo

Getting it So Very Wrong in Rails - Foreman, Byebug and Debug

Pizza courtesy of Pizza for Ukraine!

Donate Now to Pizza for Ukraine

 

Last Updated On: 2025-09-01 04:31:52 -0400

Every so often a perfect storm of interrelated circumstances takes you by surprise and causes you to go awry. In my case, I made a few changes to how I develop Rails applications and lost, temporarily, the ability to interactively debug things. Let me explain.

For a very long time, I’ve developer Rails applications simply by running:

bin/rails s -p5000

This runs the Rails server on port 5000 and simply dropping in the statement:

byebug

would launch the Ruby debugger – even in a running controller – and I could debug with great ease.

And then ByeBug was replaced with debug and this and I noticed that I could no longer interactively debug in the same way. Yes I would see the code stop executing and then I would try and enter commands but they never, ever worked.

Finally I threw up my hands and assumed one of three things:

  1. Either I’m stupid and can’t figure it out.
  2. Or there’s something wrong with the debugger and a future patch will fix it.
  3. Or I’m just missing something.

I finally took the time to dig into it again this morning and what I realized was that at the time this started happening for me, I also made the shift to using Foreman:

foreman start -f Procfile.dev

for all my Rails development. And, when I realized that, that gave me the answer:

Foreman was grabbing my input and it was never getting to the debugger!

So this means that if I want to debug interactively, I need to:

No matter how experienced you are, it is terribly easy to mistake correlation for causation.