Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use the keyboard to break into ruby-debug running a rails app?

I'm running ruby-debug with bundle exec rdebug script/server on Rails 2.3. When I press Ctrl-C, it exits the entire program and the debugger. I want it to stop execution of the program and bring me into a debugger session.

I tried catch Interrupt but it didn't work. Is there an exception that gets called when I stop rails with Ctrl-C that would be good to use for this purpose? Or is there another way?

What I want is the equivalent of pressing the Break (pause) button in Visual Studio (I haven't yet done this with a Rails IDE).

like image 200
Benjamin Atkin Avatar asked Dec 05 '25 13:12

Benjamin Atkin


2 Answers

I recommend pry over ruby-debug. Install the gem and then you can just stick this into your code where you want to debug:

binding.pry
like image 180
klochner Avatar answered Dec 09 '25 19:12

klochner


you should just drop a debugger line in your code, this will automatically create a debugging session.

like image 24
apneadiving Avatar answered Dec 09 '25 20:12

apneadiving



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!