# Connecting to a running ruby process

**URL:** <https://www.ruby-forum.com/t/connecting-to-a-running-ruby-process/158090>\
**Category:** Ruby\
**Created:** [January 19, 2009, 10:23am UTC](https://www.ruby-forum.com/t/connecting-to-a-running-ruby-process/158090 "2009-01-19T10:23:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![piyush\_r](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/73ab20/32.png) [@piyush\_r](https://www.ruby-forum.com/u/piyush_r)\
**Post date:** [January 19, 2009, 10:23am UTC](https://www.ruby-forum.com/t/connecting-to-a-running-ruby-process/158090/1 "2009-01-19T10:23:59Z")

</div>

Hi!  
Is there any way you can connect to a running ruby process (for instance  
a  
mongrel) and ‘talk’ to it like we can do in lisp using slime ?  
For instance in you may connect to a running lisp image (like a  
hunchentoot  
web server) and inspect variables as they get created and destroyed. I  
find  
such a ‘back-door’(if we may call it) very powerful. I remember there  
was  
something called a breakpoint or debug built into rails. However that is  
not  
what I am actually looking at.

Piyush

---

<div class="post-metadata">

**Author:** ![piyush\_r](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/73ab20/32.png) [@piyush\_r](https://www.ruby-forum.com/u/piyush_r)\
**Post date:** [January 19, 2009, 11:05am UTC](https://www.ruby-forum.com/t/connecting-to-a-running-ruby-process/158090/2 "2009-01-19T11:05:43Z")

</div>

> Hi!  
> Is there any way you can connect to a running ruby process (for instance a  
> mongrel) and ‘talk’ to it like we can do in lisp using slime ?  
> For instance in you may connect to a running lisp image (like a hunchentoot  
> web server) and inspect variables as they get created and destroyed. I find  
> such a ‘back-door’(if we may call it) very powerful. I remember there was  
> something called a breakpoint or debug built into rails. However that is not  
> what I am actually looking at.
> 
> Piyush

Look at LiveConsole:  
[http://rubyforge.org/projects/live-console/](http://rubyforge.org/projects/live-console/)  
(Maybe it isn’t directly what you need, but it might help)

–  
“Configure complete, now type ‘make’ and PRAY.”

```
            (configure script of zsnes - www.zsnes.com)

```

---

<div class="post-metadata">

**Author:** ![piyush\_r](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/73ab20/32.png) [@piyush\_r](https://www.ruby-forum.com/u/piyush_r)\
**Post date:** [January 19, 2009, 11:33am UTC](https://www.ruby-forum.com/t/connecting-to-a-running-ruby-process/158090/3 "2009-01-19T11:33:11Z")

</div>

Piyush R. wrote:

> Hi!  
> Is there any way you can connect to a running ruby process (for instance  
> a  
> mongrel) and ‘talk’ to it like we can do in lisp using slime ?

Try the ruby-debug gem (which is what rails uses). Unfortunately, the  
supplied documentation is pretty poor, but there is a pretty good doc at

> **[ruby-debug](https://bashdb.sourceforge.net/ruby-debug.html)**
>
> ruby-debug

Separate process debugging can be done via rdebug command line flags, or  
by calling Debugger methods explicitly:

$ cat p1.rb  
require ‘rubygems’  
require ‘ruby-debug’

Debugger.wait\_connection = true  
Debugger.start\_remote  
Debugger.post\_mortem

Debugger.breakpoint  
a = 1 - 1  
b = 2 / a  
c = a + b  
puts c

$ ruby p1.rb

In another window: rdebug -c to single step, inspect variables etc. in  
the first process.
