My .pryrc for debugging and productivity

I love pry!

See this if you’re on zeitwerk and moving away from byebug:

If you’re still on byebug, keep reading:

Here’s my .pryrc

Gems I use for Pry:

  gem "pry"
  gem "pry-rails"
  gem "pry-byebug"
  gem "pry-doc"
  gem "pry-rescue"
  gem "awesome_print"

Commands for Help

Once you’ve installed you, can run:

Tip: Run help alias

  !!!                Alias for `exit-program`
  !!@                Alias for `exit-all`
  $                  Alias for `show-source`
  ?                  Alias for `show-doc`
  @                  Alias for `whereami`
  bb                 Alias for `break`
  breakpoint         Alias for `break`
  cc                 Alias for `continue`
  clipit             Alias for `gist --clip`
  dd                 Alias for `down`
  ff                 Alias for `frame`
  file-mode          Alias for `shell-mode`
  fin                Alias for `finish`
  find-routes        Alias for `find-route`
  h                  Last 20 commands
  hG                 Commands matching expression ever used
  hg                 Up to 20 commands matching expression
  history            Alias for `hist`
  hr                 Hist -r <command number> to run a command
  nn                 Alias for `next`
  quit               Alias for `exit`
  quit-program       Alias for `exit-program`
  reload-method      Alias for `reload-code`
  show-method        Alias for `show-source`
  ss                 Alias for `step`
  uu                 Alias for `up`
  ww                 Alias for `whereami`

or run more_help

Helpful shortcuts:
hh  : hist -T 20       Last 20 commands
hg : hist -T 20 -G    Up to 20 commands matching expression
hG : hist -G          Commands matching expression ever used
hr : hist -r          hist -r <command number> to run a command

Samples variables
a_array  :  [1, 2, 3, 4, 5, 6]
a_hash   :  { hello: "world", free: "of charge" }

helper   : Access Rails helpers
app      : Access url_helpers

require "rails_helper"              : To include Factory Girl Syntax
include FactoryGirl::Syntax::Methods  : To include Factory Girl Syntax

or if you defined one...
require "pry_helper"              : To clear sidekiq
Sidekiq.redis { |r| puts r.flushall } : Another clear of sidekiq

Debugging Shortcuts
ss  :  step
nn  :  next
cc  :  continue
fin :  finish
uu  :  up
dd  :  down
ff  :  frame
bb  :  break
ww  :  whereami
1 Like

Here are a few more tips:

  1. I mostly use Pry rather than RubyMine because it’s way faster to get to the debugger. You can modify the Rails app without restarting.
  2. You must not run the Rails command within the context of foreman. If you’re using foreman to start Rails and other processes, you will need to either comment out the Rails process or run foreman like this: foreman start -f -m webpack-client-bundle=1,webpack-server-bundle=1 where webpack-client-bundle and webpack-server-bundle are your processes to start.
  3. If you run puma by default, you might want to switch the application server for debugging so that you don’t have multiple threads going at once. Running rails s might do the trick.

Be sure to also see:


I am new to pry. I am not running rails just ruby and rspec. How do I get the .pryrc aliases to work for me? Is there a command I need to run?

Thank you,