> ## Content Index
> Fetch the complete content index at: https://til.codes/llms.txt
> Use this file to discover other available public pages before exploring further.

# Disable pry and exit debugger without killing the main program in Ruby
- URL: https://til.codes/disable-pry-and-exit-debugger-without-killing-the-main-program-in-ruby/
- Published: 2017-11-17T08:38:36.000Z
- Updated: 2017-11-19T16:02:31.000Z
- Author: Manu Ajith
- Tags: ruby, debugging, pry, #Import 2024-07-13 21:01

You ever ran into a situation where you had a huge loop running and you put a `binding.pry` within that loop for debugging and wondered how the hell you would exit the debugger?

The answer is simple

`disable-pry` is your saviour.!

[via GIPHY](https://giphy.com/gifs/loki-saviour-l2QEjYgve6wmqLKog?ref=til.codes)

This has got its downside though, this will disable any further invocations of the `pry` again.

Under the hood its disabling the whole pry and setting `ENV['DISABLE_PRY'] = true`

To re-enable pry for any further debugging you will have to clear the ENV var by `ENV['DISABLE_PRY'] = nil`

I have defined a helper method `enable_pry` with the following inside my `.pryrc` for my convenience.

```
def enable_pry
  ENV['DISABLE_PRY'] = nil
end

```

Credits where its due: [https://stackoverflow.com/questions/8015531/how-do-i-step-out-of-a-loop-with-ruby-pry](https://stackoverflow.com/questions/8015531/how-do-i-step-out-of-a-loop-with-ruby-pry?ref=til.codes)

Happy coding.!!