Instantly share code, notes, and snippets.

What would you like to do?
Pry Cheat Sheet

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by
  • pry -r ./config/environment.rb - load your rails into a pry session


  • help ls -- Display command options for pry command ls
  • ls <Object> -- Show all of the available methods that can be called by an object
  • _ -- Last eval
  • ? <Object> -- Shows more information (doc) about an object, or method
  • _file_ -- Represent the last file Pry touched
  • wtf? -- Print the stack trace, same as _ex_.backtrace
  • $ -- Show source, shortcut for show-source
  • edit Class -- Open file in $EDITOR
  • edit Class#instance_method -- Open file in $EDITOR
  • <ctrl+r> -- Search history
  • _out_ -- Array of all outputs values, also _in_
  • cd <var> -- Step into an object, change the value of self
  • cd .. -- Take out of a level
  • binding.pry -- Breakpoint
  • edit --ex -- Edit the file where the last exception was thrown
  • .<Shell> -- Runs the command
  • whereami -- Print the context where the debugger is stopped
  • whereami 20 -- Print the context 20 lines where the debugger is stopped
  • ; -- Would mute the return output by Ruby
  • play -l -- Execute the line in the current debugging context


  • next -- execute next line
  • step -- step into next function call
  • continue -- continue through stack


  • rescue rspec -- break on exception in rspec
  • rescue rails server -- break on exception in rails server
  • try-again -- run last failing spec, reloads the file not the enviornment

This comment has been minimized.

SteveBenner commented Dec 24, 2014

Thanks for putting this up! I ⭐️ ‘d but also modified it to add syntax highlighting, which I think makes it quite a bit prettier!

Simple regex I used: (?<=^- )(.*)(?= *--+ )


This comment has been minimized.

bsimpson commented Feb 23, 2015

Just a note on showing the backtrace: The command is _ex_.backtrace. Looks like markdown ate the underscores


This comment has been minimized.

stujo commented May 21, 2015

Thank you!


This comment has been minimized.

geocodinglife commented Apr 10, 2016

Info very helpful,


This comment has been minimized.

ghost commented Jun 15, 2017

very helpful, thanks


This comment has been minimized.

cmdallas commented Mar 9, 2018

This is amazing. Thanks!


This comment has been minimized.

hailengc commented Mar 26, 2018


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