Skip to content

Instantly share code, notes, and snippets.

@caioertai
Last active February 8, 2023 00:17
Show Gist options
  • Save caioertai/50cf717a2a2dbd5301c350d428342d35 to your computer and use it in GitHub Desktop.
Save caioertai/50cf717a2a2dbd5301c350d428342d35 to your computer and use it in GitHub Desktop.

pry-byebug Cheatsheet

Instalation

Make sure you have the gem installed:

$ gem install pry-byebug

Usage

  1. Require the gem at the top of your file
  2. Add the binding.pry to your code

1. Require the gem at the top of your file

require 'pry-byebug'
# Top here ☝️

# ...
# Tons of code
# ...

2. Add the binding.pry to set your stop marker. It stops the execution of the code before the next line.

puts 'Hello World'
binding.pry
puts 'Goodbye World' # <<< Execution will stop before this

It will look like this:

    1: puts 'Hello World'
    2: binding.pry
 => 3: puts 'Goodbye World'

[1] pry(main)> # <<< You can type commands here

Most useful commands

next

Step over to the next line within the same frame. Also takes an optional numeric argument to step multiple lines.

continue

Continue program execution until next marker (yes, you can set multiple binding.pry in your code).

!!!

Closes the pry session. Pretty handy if you're stuck on an endless loop.

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