Skip to content

Instantly share code, notes, and snippets.

What would you like to do?

ruby-debug cheatsheet

s[tep] -- step into next call

n[ext] -- step over next call

l[ist] = -- show the current line, in context. e.g.:

   26          end
   27        end
   29        # Send a start notification with +name+ and +payload+.
   30        def start(name, payload)
=> 31          @notifier.start name, @id, payload
   32        end
   34        # Send a finish notification with +name+ and +payload+.
   35        def finish(name, payload)

l[ist] -- show next context (i.e. likel[ist] =, but show the lines further down)

l[ist] - -- show previous context (i.e. like l[ist] =, but show the lines further up)

info stack or backtrace -- show the call stack, along with current position. e.g.:

    #0 ActionController::Metal.session
       at line /Users/mziwisky/gems/gems/actionpack-4.0.2/lib/action_controller/metal.rb:129
--> #1 ApplicationController.current_user
       at line /Users/mziwisky/repos/gallery/app/controllers/application_controller.rb:61
    #2 ApplicationController.require_oauth_login
       at line /Users/mziwisky/repos/gallery/app/controllers/application_controller.rb:36
    #3 CoursesController._run__734297631673027883__process_action__callbacks
       at line /Users/mziwisky/gems/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:407
    #4 ActiveSupport::Callbacks.run_callbacks(kind#Symbol)
       at line /Users/mziwisky/gems/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:80

up and down -- navigate thru the call stack

info args -- show the arguments for the current function

v[ar] l[ocal] or info locals -- show local variables

v[ar] i[nstance] <object> -- show instance variables [of <object> if specified]

display -- lets you enter an expression to be evaluated and printed at every step, so you can see how things change as the program executes. see help display for usage.

info and show -- used to expose lots of information. try them out.


When in doubt, help, and help <command-name>

and maybe check


save the following as ~/.rdebugrc

set autoeval
set autolist
set autoreload

set autoeval causes any commands that are not normally understood to be debugger commands to get evaluated as though they were Ruby commands.

set autolist runs a list command every time the debugger stops (i.e. shows you where the instruction pointer is)

set autoreload causes the debugger to reload the source if it has changed during debugging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment