Pry: Disable binding.pry invocation at runtime

Created on 15 Jan 2013  路  5Comments  路  Source: pry/pry

Sometimes after putting a binding.pry in a block of code, I find out after hitting that line that the block is actually called from a tight loop and I'm left hitting Ctrl-D over and over until it breaks out of the loop.

I'm wondering if it's possible to do something like:

[1] pry(#<TwistyPassages::AllAlike>)>
Ctrl-D
[1] pry(#<TwistyPassages::AllAlike>)>
Ctrl-D
[1] pry(#<TwistyPassages::AllAlike>)>Pry.disable!
[1] pry(#<TwistyPassages::AllAlike>)>
Ctrl-D
Out of the maze!

Maybe there's an existing way to do it?

Most helpful comment

Hey @avit, The next release of pry (due some time in the next week) will have a disable-pry command which does exactly what you want :).

Before that landed I often used edit-method to remove the binding.pry from the current running instance of the program (if you pass -p then it'll only patch the running code, not change the file).

All 5 comments

Hey @avit, The next release of pry (due some time in the next week) will have a disable-pry command which does exactly what you want :).

Before that landed I often used edit-method to remove the binding.pry from the current running instance of the program (if you pass -p then it'll only patch the running code, not change the file).

Wonderful, thanks!

Very nice, is there a way to reactivate pry as well?

I'm using it to debug my rails app, and often I would like to stop debugging the current request, operate a change and then make a new http request and start debugging that,

with disable-pry I can do the first part, but for resume debugging I currently need to restart the rails server.

thanks

@DonGiulio I think raise-up would be a better fit for your use case. It raises a RuntimeError from the point where binding.pry was invoked.

Hi @rf-,

Thanks for your quick reply, raise-up blocks the execution of my app, I would like to let it continue, so that I can see what is the result of the whole script.

that's a nice idea to stop it forcibly though, thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vaidehijoshi picture vaidehijoshi  路  3Comments

alexjfisher picture alexjfisher  路  3Comments

jjgh picture jjgh  路  6Comments

alexdowad picture alexdowad  路  6Comments

mbbroberg picture mbbroberg  路  4Comments