I'm trying to use pry and pry-byebug to step through the execution of some code in a Rails console. I started the console with
pry -r ./config/environment
I then set a breakpoint:
break Foo#bar
Then make a new Foo
and call bar
on it:
Foo.new.bar
I expected step into Foo#bar
, but instead the method just executed normally.
Is there some way to get this workflow to work?
I found the answer: the debugger is not re-entrant. So you need to do this:
[1] pry(main)> binding.pry
[1] pry(main)> break Foo#bar
Breakpoint 1: Foo#bar (Enabled) :
6: def bar
7: end
[2] pry(main)> c # continue and exit the debugger we started on the first line
=> nil
[3] pry(main)> Foo.new.bar
Breakpoint 1. First hit.