How to debug pure ruby programs in RadRails

977 views Asked by At

I am new to Ruby so have installed RadRails, Ruby 1.92 and ruby-debug-ide19. I have a very simple ruby program that prints hello world. But when I try and place a breakpoint in the code and run in debug mode all i get is the following line on the console:

Fast Debugger (ruby-debug-ide 0.4.9) listens on :51224

Why does it need to listen on a port anyway? And how can i get it to run my program until the breakpoint?

2

There are 2 answers

0
the Tin Man On

Personally, I don't bother with an IDE for debugging. I prefer to be closer to the metal... err... command-line, so I use ruby-debug19 from the command-line.

rdebug some_file_to_debug

For the basics use:

  • b to set your breakpoints
  • n to step over methods
  • s to step into methods
  • c to continue running after hitting a breakpoint
  • c n to run to a particular line then stop
  • p to display a value
  • h will display the built-in help
  • irb drops into IRB with the current variables pre-initialized so you can poke at things with a stick and see what they'll do.

More docs are at the Ruby-Debug site.

0
Christopher Williams On

It uses the port to communicate between the IDE and the ruby-debug process, ruby-debug-ide is opening a port and waiting for the IDE to connect to it, but that happens pretty must instantly.

From what you've stated, debugging should already be working: You can right-click and select Toggle breakpoint, or double-click on the left-hand gutter of the editor. When your program hits any enabled breakpoint line the program should suspend and you can inspect variables, the stackframes, execute arbitrary code, step into or through your code, continue, etc.