Skip to content
antoinelyset edited this page Dec 4, 2012 · 13 revisions
### Quick Menu:
  1. / pry-debugger
  2. / pry-coolline
  3. / pry-remote
  4. / pry-remote-em
  5. / pry-stack_explorer
  6. / pry-exception_explorer
  7. / pry-vterm_aliases
  8. / pry-syntax-hacks
  9. / pry-em
  10. / pry-theme
Author: Nixme

Pry-debugger is a great third-party plugin that provides the long-awaited next ,step and continue commands to Pry. Once this gem is installed, you invoke Pry as normal, however entering next will advance execution along one line:

[1] (pry) main: 0> next

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

    1: require 'pry-debugger'
    2:
    3: def hello
    4:   binding.pry
 => 5:   x = 20
    6: end
    7:
    8: hello

The project is still under development and has some work to go (namely thread-safety) but this gem, together with pry-stack_explorer provides a very capable alternative to ruby-debug, and should satisfy many user's needs for basic debugging primitives.

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 comand 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

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