Skip to content
Clément Morisset edited this page Mar 6, 2024 · 45 revisions
  1. pry-byebug / code
  2. pry-byetypo / code
  3. pry-coolline / code
  4. pry-remote / code
  5. pry-remote-em / code
  6. pry-stack_explorer / code
  7. pry-exception_explorer / code
  8. pry-vterm_aliases / code
  9. pry-em / code
  10. pry-theme / code
  11. pry-toys / code
  12. pry-macro / code
  13. pry-debugger / code
  14. pry-inline / code
  15. pry-loudmouth / code
  16. pry-debugger-jruby / code
  17. pry-shell / code
  18. pry-nav / code

Currently non-functional

  1. pry-syntax-hacks / code issue
  2. pry-state / code issue
  3. pry-auto_benching / code issue
Author: deivid-rodriguez Ruby versions: 2.0+ MRI

Adds next ,step, finish and continue commands to Pry for stepping through your program's code and up, down and frame commands for callstack navigation.

[1] (pry) main: 0> step

From: ./y.rb @ line 4 in Object#hello:

    1: require 'pry-byebug'
    2:
    3: def hello
 => 4:   puts 'Hello'
    5: end
    6:
    7: binding.pry
    8: hello

For Ruby 1.9 alternatives, checkout pry-debugger and pry-stack_explorer

Back to top

Author: Clément Morisset

Pry-byetypo autocorrects typos in your Pry console.

This plugin captures exceptions that may arise from typos and deduces the correct command based on your database information and session history.

Before
[2] pry(main)> Usert.last
NameError: uninitialized constant Usert
from (pry):2:in `__pry__'
[3] pry(main)>
After
[1] pry(main)> Usert.last
I, [2024-01-13T20:00:16.280710 #694]  ERROR -- : uninitialized constant Usert
I, [2024-01-13T20:00:16.281237 #694]  INFO -- : Running: User.last
=> #<User id: 1, email: "yo@email.com">

Back to top

Author: Mon_Ouie Ruby versions: 1.9.2+ MRI

Pry-coolline is a nifty little Readline replacement that takes advantage of the new stdlib io-console library to provide live syntax highlighting for user input. It's unfortunately limited to Ruby versions 1.9.2+ and MRI, but generally works well.

Back to top

Author: Mon_Ouie

Pry-remote (along with its cousin pry-remote-em) enables you to start instances of Pry in a running program and connect to those instances over a network or the Internet. Once connected you can interact with the internal state of the program. This plugin comes into its own when used with tools such as Pow, enabling you to get a Pry session in places not normally possible. pry-remote is also notable for having pry-nav support.

We set up the server as follows:

require 'pry-remote'

class Foo
  def initialize(x, y)
    binding.remote_pry
  end
end

Foo.new 10, 20

Back to top

Author: simulacre Ruby versions: 1.9.2+ MRI

Pry-remote-em is a sophisticated EventMachine-based alternative to pry-remote. It adds user authentication and SSL support along with tab-completion and paging. It also allows multiple clients to connect to the same server, and multiple servers to run on the same computer and even within the same process. pry-remote-em is one of the most exciting projects in the Pry ecosystem, as it opens up possibilities for multi-user remote-debugging/exploration, as well as educational applications. It is also just fun to interact with other programmers in a live environment. One limitation of pry-remote-em at the moment is the lack of pry-nav support, but this will be added in the future.

Starting the pry-remote-em server:

require 'pry-remote-em/server'

class Foo
  def initialize(x, y)
    binding.remote_pry_em
  end
end

EM.run { Foo.new 10, 20 }

Back to top

Author: banisterfiend Ruby versions: 1.9.2+ MRI

Pry-stack_explorer  is a powerful plugin that enables navigation of your program's call-stack. From the point a Pry session is started, you can move up the stack through parent frames, examine state, and even evaluate code. Unlike some other debuggers, pry-stack_explorer incurs no runtime cost and enables navigation right up the call-stack to the birth of the program. Together with the pry-nav plugin, it should provide the user with a fairly complete and fast debugging experience in Ruby 1.9.2+ MRI. Pry-stack_explorer provides the show-stack command as well as up and down

[1] (pry) main: 0> show-stack

Showing all accessible frames in stack (5 in total):
--
=> #0 [method] gamma <Object#gamma()>
 #1 [method] beta <Object#beta()>
 #2 [method] alpha <Object#alpha()>
 #3 [eval] <main>
 #4 [top] <main>

Back to top

Author: banisterfiend Ruby versions: 1.9.2+ MRI

Pry-exception_explorer is an interactive error console for MRI Ruby 1.9.2+ inspired by the Hammertime gem, which was in turn inspired by consoles found in the Lisp and Smalltalk environments. Unlike the Hammertime gem, we are dropped into the actual context of the exception (with full access to local state) and can even walk the stack (using pry-stack_explorer, discussed above) to isolate the cause of the exception. Rudimentary support for some C-level exceptions is also provided and activated with a command line switch. Another feature of pry-exception_explorer is the ability to define exactly when it kicks-in. This can be as simple as specifying an exception type, or as sophisticated as an assertion over the entire state of the stack. The Plymouth gem works by defining a number of stack assertions for each of the testing libraries it supports. In the example below, we configure a stack assertion so that exception explorer starts when an ArgumentError is raised, but only if the exception context is an instance of MyClass and the parent's context is an instance of MyCallingClass:

EE.intercept do |frame, ex|
  ex.is_a?(ArgumentError) && frame.klass.is_a?(MyClass)) &&
  frame.prev.klass.is_a?(MyCallingClass)
end

However, this plugin has been deprecated in favor of pry-rescue.

Back to top

Author: EnvyGeeks Ruby versions: 1.8.7+, 1.9+

Pry-VTerm_Aliases brings your bash and zsh aliases into Pry as known shell commands.

Back to top

Author: Conrad Irwin Ruby versions: all

Pry-syntax-hacks adds some syntactic sugar to Pry. Most usefully it allows you to look at instance variables of objects: user.@password, call private/protected methods on objects: user.!hash_password('test'). It also lets you access methods: passwords.map user.&hash_password, and access variables in previously active pry bindings (a.la. cd): puts ../a.

Back to top

Author: Conrad Irwin Ruby versions: all

Pry-em adds an em: command which allows you to run code in an EventMachine context. It also waits for asynchronous operations to complete, and binds to the callback and errback of deferrables.

Back to top

Author: Kyrylo Silin
Ruby versions: all

Pry Theme plugin helps you to customize your Pry colors via prytheme files. It adds pry-theme command, which allows you to test themes on the fly and and install new ones.

Put your Pry theme in ~/.pry/themes directory and set it up in your config:

# ~/.pryrc
Pry.config.theme = "theme-name"

Back to top

Author: Alex Riabov
Ruby versions: all

Pry Toys adds easy ways to create complex throwaway Ruby object in pry. Now you can quickly create Array of Floats:

Array.toy(3, Float) # => [1.0, 2.0, 3.0]

or Hash with 300 keys:

Hash.toy(300) # => { a: 1, b: 2, ..., kn: 300 }

or String with 2 words:

String.toy(2) # => "ttttttt oooo"

After gem is installed, these toy / throwaway Ruby objects are going to be available for creation when pry is started. To learn more about other arguments you can use to customize toy objects, click here

Back to top

Author: Brandon Weaver
Ruby versions: all

Pry Macro allows you to record a workflow, define a command, and save macros to your .pryrc. This works with both plain ruby and pry commands.

[1] pry(main)> record
[2] pry(main)> 1
=> 1
[4] pry(main)> ls
self.methods: inspect  to_s
locals: _  __  _dir_  _ex_  _file_  _in_  _out_  _pry_

[5] pry(main)> stop -n testing -d 'A test command!'

Run it like any other command:

[6] pry(main)> testing
=> 1
self.methods: inspect  to_s
locals: _  __  _dir_  _ex_  _file_  _in_  _out_  _pry_

Like it? You can save it and have it automatically append to your PryRC:

[10] pry(main)> save-macro testing

Back to top

Author: Nixme Ruby versions: 1.9 MRI

This is the old debugging plugin for Ruby 1.9. Still useful to aid upgrading or for legacy code.

Back to top

Author: Sudhagar Ruby versions: 2.0+ MRI

Pry State lets you can see the values of the instance and local variables in a pry session.

[1] pry(#<UsersFetcherService>)> n

From: /Users/sudhagars/Projects/authentication-service/app/services/users_fetcher_service.rb @ line 17 UsersFetcherService#fetch:

    11: def fetch
    12:   a = 'dummy string'
    13:   b = ['dummy', 'array']
    14:   binding.pry
    15:   apply_access_type_filter
    16:   apply_third_party_filter
 => 17:   reject_protected_auth
    18:   sort_auths
    19:   auths
    20: end

@user                    #<User:0x007fd7da194790>
@access_type_filter      "owner"
@third_party_filter      len:0 []
@auths                   len:3 [#<Auth:0x007fd7d6fb55a8 @new_record=false, @attrib...
a                        "dummy string"
b                        len:2 ["dummy", "array"]
Author: seikichi Ruby versions: 2.0+ MRI

Pry Inline enables the inline variables view like RubyMine.

From: /Users/seikichi/src/book/ror-tutorial/sample_app/app/controllers/users_controller.rb @ line 54 UsersController#following:
   49: def following
   50:   @title = "Following" # @title: "Following"
   51:   @user = User.find(params[:id]) # @user: #<User id: 1751, name: "Person 68", email: "person_68@example.com", created_at: "2015-09-20 05:58:40", updat
   52:   @users = @user.followed_users.paginate(page: params[:page]) # @users: #<ActiveRecord::AssociationRelation [#<User id: 1752, name: "Person 69", email
   53:   binding.pry
=> 54:   render 'show_follow'
   55: end

[1] pry(#<UsersController>)>

Back to top

Author: sagotsky Ruby versions: 2.0+ MRI

Pry Loudmouth makes pry sessions more visible. It changes the process title and emits an alarm character whenever the session begins.

Back to top

Author: ivoanjo Ruby versions: JRuby 9.1.3.0+

pry-debugger-jruby is a Pry debugging gem with JRuby support. Similarly to pry-byebug above, it adds the next ,step, finish and continue commands to Pry for stepping through your program's code and the break command to set breakpoints.

    3: def hello
    4:   puts 'Hello'
    5: end
    6: 
    7: binding.pry
 => 8: hello

[1] pry(main)> step

From: y.rb @ line 4 Object#hello:

    3: def hello
 => 4:   puts 'Hello'
    5: end
Author: r-obert; resurrected by estum Ruby versions: 2.1+ MRI

pry-auto_benching.rb automatically benchmarks input given to Pry.

[7] pry(main)> sleep 0.2
=> 0
[8] 0.2s (main)> Net::HTTP.get_response URI.parse('https://github.com')
=> #<Net::HTTPOK 200 OK readbody=true>
[9] 1.34s (main)> Net::HTTP.get_response URI.parse('https://www.ruby-lang.org')
=> #<Net::HTTPOK 200 OK readbody=true>
[10] 1.53s (main)>

Back to top

Author: Mehmet Emin Inac

Pry-shell Allows you to control multiple Pry sessions running on multiple processes via the standalone ruby process called pry-shell.

First, we need to spinoff our standalone pry-shell application, like so;

$ pry-shell

Then we instantiate the Pry session which can be managed by the pry-shell application as follows:

require 'pry-shell'

class Foo
  def initialize(x, y)
    binding.pry_shell
  end
end

Foo.new 10, 20

The Pry session will be available under the Available Sessions menu on pry-shell application.

Back to top