How to debug Ruby scripts

Viewed 179231

I copied the following Ruby code from the Internet and made a few changes but it doesn't work.

What can I do to debug the program by myself?

17 Answers

If you are using RubyMine, debugging ruby scripts is simple and straightforward.

Suppose you have a Ruby script hello_world.rb

1. Set breakpoints

Set a breakpoint at line 6 as below.

enter image description here

2. Start debugging

Now you can just start the debugger to run the script:

enter image description here

enter image description here

3. Inspect variables, etc.

Then when the execution hits a breakpoint, you'll be able to inspect variables, etc.

enter image description here

Further information for your reference

  1. If you would like to use RubyMine to do remote debugging, you can do so.
  2. If you would like to use RubyMine to remote debug rails running inside a docker, it is also straightforward.
Related