Rails Byebug Did Not Stop Application

Rails Byebug Did Not Stop Application

When using docker-compose in combination with byebug this needs to be added to make it work properly. Found in this blog post

Add this to docker-compose.yml

web:
...
stdin_open: true
tty: true

Then run docker-compose in deamonized mode and attach to the web container with docker:

docker-compose up -d
docker attach myappname_web_1

byebug, next into application code only

I use c n to continue to a particular line n. Byebug will run at full-speed, then stop at the line you gave it. That means that gems or not, they won't be noticed by you as they'll be processed at high-speed.

The built-in help says:


(byebug) help continue
c[ont[inue]][ nnn]

Run until program ends, hits a breakpoint or reaches line nun

Reasons rails is not stopping at debugger

This is a known issue in the debugger gem, see here (bullet point number three).

It seems that you are interested in why it doesn't work. The following is the explanation:

  • What debugger does is watching some events provided by ruby that tell the debugger when to stop. In this case, the debugger tracks what we call a line event that is triggered once per line executed, so in the case of the last line of a method, the debugger will stop in the next line event, which actually happens outside the method that is being debugged.

  • In byebug, however, I also track what we call return events, that are called every time a method finishes. That's why I'm able to stop execution before the method actually finishes.

Hope this helps.

Ruby byebug never stops

I had downgrade to a lower version of byebug and it works. Not sure what incompatibilities there may have been with the latest version. Using 3.5.1 worked for me.

gem 'byebug', '~> 3.5.1'


Related Topics



Leave a reply



Submit