Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use ruby-debug inside Emacs?

I know Emacs has some sort of integration with gdb (though I never used it) to jump through files as you debug a program. I'd like to do the same with Ruby programs.

like image 698
agentofuser Avatar asked Aug 31 '09 20:08

agentofuser


People also ask

How do I run Ruby in debug mode?

To help deal with bugs, the standard distribution of Ruby includes a debugger. In order to start the Ruby debugger, load the debug library using the command-line option -r debug. The debugger stops before the first line of executable code and asks for the input of user commands.

How do I debug with pry?

Invoking pry debugging To invoke the debugger, place binding. pry somewhere in your code. When the Ruby interpreter hits that code, execution stops, and you can type in commands to debug the state of the program.


2 Answers

As erenon said, use ruby debug, which provides a library for emacs that lets you use it just as gdb.

Install rdebug by issuing this command on your terminal(the sudo is optional, depending on your system):

<sudo> gem install ruby-debug

You then need to download the ruby-debug-extra file from rubyforge, and install it in the standard way.

  sh ./configure
  make
  make test # optional, but a good idea
  sudo make install

This gives you the elisp files for the interaction with rdebug, plus documentation for ruby-debug that can be viewed from within emacs.

AJ

like image 100
Adulteratedjedi Avatar answered Sep 18 '22 09:09

Adulteratedjedi


There is another emacs to ruby-debug interface. See https://github.com/rocky/emacs-dbgr/wiki .

More generally, it works with other ruby debuggers and other debuggers in general.

like image 45
rocky Avatar answered Sep 22 '22 09:09

rocky