# Can the debugger be called from within an interactive sessio

**URL:** <https://www.ruby-forum.com/t/can-the-debugger-be-called-from-within-an-interactive-sessio/56348>\
**Category:** Ruby\
**Created:** [December 2, 2005, 6:41am UTC](https://www.ruby-forum.com/t/can-the-debugger-be-called-from-within-an-interactive-sessio/56348 "2005-12-02T06:41:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![billmcn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/53a042/32.png) [@billmcn](https://www.ruby-forum.com/u/billmcn)\
**Post date:** [December 2, 2005, 6:41am UTC](https://www.ruby-forum.com/t/can-the-debugger-be-called-from-within-an-interactive-sessio/56348/1 "2005-12-02T06:41:24Z")

</div>

I’m a Ruby newbie. I’ve only been at the language for a little over a  
week, but so far I’m impressed. My language of choice for the past  
several years has been Python, so I’m trying to figure out how to do  
all my familiar Python tricks in Ruby. Mostly, this has been easy, but  
there is one thing that leaves me stumped: is it possible to start the  
debugger from within an interactive session?

For example, say I’ve written the file called “test.rb” containing the  
function “adder”.

def adder(x, y)  
x+y  
end

I can launch irb and try out the function.

irb(main):001:0\> require “test”  
=\> true  
irb(main):002:0\> adder(3,4)  
=\> 7

What I’d like to do is start the debugger from within the interactive  
session and step into the function. For a similar Python program you  
could do the following

> > > import test  
> > > import pdb  
> > > pdb.run(“test.adder(3,4)”)  
> > > (1)?()  
> > > (Pdb) s  
> > > –Call–  
> > > /Users/bill/temp/test.py(1)adder()  
> > > -\> def adder(x,y):  
> > > (Pdb) n  
> > > /Users/bill/temp/test.py(2)adder()  
> > > -\> return x+y

I haven’t been able to figure out if the Ruby debugging environment has  
a similar feature. I’ve searched documentation, played with debug, and  
glanced at the debug.rb source, to no avail.

Of course I could write a wrapper script that calls adder and run that  
with “ruby -rdebug wrapper.rb”, but that loses the convenience of being  
able to work entirely in the interactive mode, which I find very  
useful, particularly in the early stages of development.

Thanks for your help.
