Skip to content
Kyrylo Silin edited this page May 9, 2013 · 4 revisions
[Back to Main Menu](/pry/pry/wiki)

Overview

Using the pry-remote gem we can start Pry remotely and connect to it using DRb. This allows us to access the state of the running program from anywhere.

This also makes Pry usable with tools such as Pow.

Installation

gem install pry-remote

Usage

Here's a program starting pry-remote, we simply use binding.remote_pry instead of the normal binding.pry:

    require 'pry-remote'

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

    Foo.new 10, 20

Running it will prompt you with a message telling you Pry is waiting for a program to connect itself to it:

 [pry-remote] Waiting for client on drb://localhost:9876

You can then connect yourself using the pry-remote executable:

$ pry-remote
From: example.rb @ line 7 in Foo#initialize:
     2:
     3: require 'pry-remote'
     4:
     5: class Foo
     6:   def initialize(x, y)
 =>  7:     binding.remote_pry
     8:   end
     9: end
    10:
    11: Foo.new 10, 20
pry(#<Foo:0x00000000d9b5e8>):1> self
=> #<Foo:0x1efb3b0>
pry(#<Foo:0x00000001efb3b0>):1> ls -l
_  _dir_  _ex_  _file_  _in_  _out_  _pry_  x  y
pry(#<Foo:0x00000001efb3b0>):1> ^D

Limitations

Paging is turned off. Tab completion does not work.

The edit command will not work for terminal editors; and will not work at all when the DRb client/server reside on different computers.

These limitations will be addressed in later releases.

Credits

pry-remote is a project by Mon Ouie. See the actual project page here.

Back to the top of the page