Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

  • Blog Navigation
ruby-debug in 30 seconds (we don't need no stinkin' GUI!)

Alfonso Bedoya, Treasure of the Sierra Madre

Many people (including me) have complained about the lack of a good GUI debugger for Ruby. Now that some are finally getting usable, I’ve found I actually prefer IRB-style ruby-debug to a GUI.

There’s good tutorial links on the ruby-debug homepage, and a very good Cheat sheet, but I wanted to give a bare-bones HOWTO to help you get immediately productive with ruby-debug.

Install the latest gem

$ gem install ruby-debug

Install the cheatsheet

$ gem install cheat
$ cheat rdebug

Set autolist, autoeval, and autoreload as defaults

$ vi ~/.rdebugrc
set autolist
set autoeval
set autoreload

Run Rails (or other app) via rdebug

$ rdebug script/server

Breakpoint from rdebug

(rdb:1) b app/controllers/my_controller.rb:10

Breakpoint in source

require 'ruby-debug'


(rdb:1) cat RuntimeError

Continue to breakpoint

(rdb:1) c

Next Line (Step Over)

(rdb:1) n

Step Into

(rdb:1) s


(rdb:1) c

Where (Display Frame / Call Stack)

(rdb:1) where

List current line

(rdb:1) l=

Evaluate any var or expression

(rdb:1) myvar.class

Modify a var

(rdb:1) @myvar = 'foo'


(rdb:1) h

There are many other commands, but these are the basics you need to poke around. Check the Cheat sheet for details.

This can also be used directly from any IDE that supports input into a running console (such as Intellij Idea).

That should get you started. So, before you stick in another ‘p’ to debug, try out ruby-debug instead!

  • Brian Takita

    rdebug also pairs very nicely with editors that have an interactive console with links, because the links will take you to where the debug cursor is.

    This includes IntelliJ Idea and I believe Eclipse and Netbeans.

  • Brian Takita

    Also, a great code snippit for you editor is:

    require ‘ruby-debug’; debugger;

    I bind it to debug

  • Chad,

    I still not get it why do u choose rdebug script/server way, if you choose Brian’s snippet, it will just work. Is there any difference in using rdebug and Brian’s snippet?

    — Anil

  • Looks useful – thanks!

    – Vasudev
    Dancing Bison Enterprises
    Software consulting and training
    Biz site:
    Blog (on software innovation):
    Quick and easy PDF creation toolkit:

  • Tom

    I am really starting to like using ruby-debug. I find that I use it most often when running my unit and functional tests. The only problem I have is that it doesnt appear to read my defaults from the .rdebugrc file in this scenario. Anyone else seen this behavior?

  • Chad Woolley


    I think the primary difference is that when you invoke via rdebug, you don’t have to modify your code to set a breakpoint. It will stop on the first line of the script you pass to rdebug, and allow you to set a breakpoint or catchpoint. Sometimes this is more convenient.

    Also, I _think_ I’ve encountered situations where using the gem didn’t work as well as rdebug, but I think this was while debugging rubygems itself.

    — Chad

  • Chad Woolley


    Yes, I’ve seen this problem where .rdebugrc is not read. There is a bug on the rdebug tracker. I think it may have been fixed in a recent version, and on previous versions only occurred sometimes (perhaps when using rdebug vs. debugger call in the code).

    If it isn’t working for me, I just manually issue ‘set autoeval’ and ‘set autolist’.

    — Chad

  • Chad Woolley

    Interesting Anecdote: Today, I was with a customer trying to debug cruisecontrol.rb. He uses NetBeans (which was the GUI debugger I referred to above that was pretty nice). However, we couldn’t get the debugger to breakpoint after a couple of minutes trying, so we used ruby-debug, which worked fine.

    In my totally biased and unscientific experience, ruby GUI debuggers seem to have problems with code that issues system calls (backticks, system(), IO.popen, etc). ruby-debug seems to handle this stuff better.

    — Chad

  • @Tom – and anyone else who experienced ruby-debugger not reading your .rdebugrc file in Rails:

    The same thing happened to me. I found that in order to get my default settings applied for ruby-debugger, I had to include the following in my environment file – I only include it locally, for development, in a file that is included, fwiw:

    require 'rubygems'
    require 'ruby-debug'
    Debugger.settings[:autoeval] = true
    Debugger.settings[:autolist] = true
    Debugger.settings[:autoreload] = true


  • Ed Ruder

    I got an error on the `Debugger.settings[:autoreload] = true` line, using ruby-debug-0.9.3. Changing this line to:

    Debugger.settings[:reload_source_on_change] = true

    Got it to work! (Gleaned from the bottom of the ruby-debug-0.9.3/cli/ruby-debug/command.rb file.)


  • Ed Ruder

    Sorry about the formatting in the post above. To clarify, I changed this:

    Debugger.settings[:autoreload] = true

    To this:

    Debugger.settings[:reload_source_on_change] = true


  • Ed, just saw your comments. Weird, I wonder why that works for me but not for you. This is in a Rails 1.2.5 app using rdebug v0.10.0.

    Perhaps we’re just on different versions of something. Glad you got it working, though.

  • asd

    Debugger.settings[:autolist] = true

    doesn’t work, has to be:

    Debugger.settings[:autolist] = 1

  • Konstantin S.

    Hi Chad,

    Link to ‘cheat sheet’ seems to not work any more.

  • Shuky Chen


    Take a look on a new sublime plugin,

    Ruby Debugger –

    This plugin allow you to visualize debugging on ruby, and RoR

    using debugger(ruby-debug fork) gem.

    Take a look also at the github repository:

  • Ananth

    Hi – Am trying to bring up rearview framework on Linux. I have some issue and wanted to debug with ruby-debug. On executing,

    $cheat rdebug

    – I see the below error.

    NotImplementedError: fork is not available on this platform.

    Can someone, please help?

  • Chad Woolley

    @ananth – A quick google indicates that error is related to JRuby. In general, the best source of answers is googling for the error message you’re getting. StackOverflow usually has some of the best answers.

    Good Luck.

    — Chad

  • Darren

    Cheat sheet link is broken

    • Stacey Schneider

      Thank you! This has been fixed.

Share This