# Debugging question

**URL:** <https://www.ruby-forum.com/t/debugging-question/117571>\
**Category:** Ruby\
**Created:** [October 18, 2007, 6:00am UTC](https://www.ruby-forum.com/t/debugging-question/117571 "2007-10-18T06:00:35Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![eggman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/51bf81/32.png) [@eggman2001](https://www.ruby-forum.com/u/eggman2001)\
**Post date:** [October 18, 2007, 6:00am UTC](https://www.ruby-forum.com/t/debugging-question/117571/1 "2007-10-18T06:00:35Z")

</div>

I run this one gem with the command "foo ". I’d like to try  
to run it off the foo.rb file so that I can debug it. However, when I  
do "ruby path/to/foo.rb " it doesn’t behave in the same way  
as "foo ". How do I need to run this program in order to  
debug it?

---

<div class="post-metadata">

**Author:** ![eggman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/51bf81/32.png) [@eggman2001](https://www.ruby-forum.com/u/eggman2001)\
**Post date:** [October 18, 2007, 3:53pm UTC](https://www.ruby-forum.com/t/debugging-question/117571/2 "2007-10-18T15:53:41Z")

</div>

maybe first  
require ‘rubygems’  
then require the file,  
maybe run it from within that directory.  
maybe do Dir.chdir to it, first, then require.

eggman2001 wrote:

> I run this one gem with the command "foo ". I’d like to try  
> to run it off the foo.rb file so that I can debug it. However, when I  
> do "ruby path/to/foo.rb " it doesn’t behave in the same way  
> as "foo ". How do I need to run this program in order to  
> debug it?

Specifics would be nice, as I don’t quite understand what you’re trying  
to do. “run a gem”?

---

<div class="post-metadata">

**Author:** ![eggman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/51bf81/32.png) [@eggman2001](https://www.ruby-forum.com/u/eggman2001)\
**Post date:** [October 19, 2007, 4:48am UTC](https://www.ruby-forum.com/t/debugging-question/117571/3 "2007-10-19T04:48:26Z")

</div>

so I installed the gem rdig. You run rdig with "rdig " and  
I’d like to debug it.

---

<div class="post-metadata">

**Author:** ![eggman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/51bf81/32.png) [@eggman2001](https://www.ruby-forum.com/u/eggman2001)\
**Post date:** [October 19, 2007, 6:09am UTC](https://www.ruby-forum.com/t/debugging-question/117571/4 "2007-10-19T06:09:36Z")

</div>

eggman2001 wrote:

> so I installed the gem rdig. You run rdig with "rdig " and  
> I’d like to debug it.

gem install ruby-debug  
rdebug rdig (maybe)  
gl

---

<div class="post-metadata">

**Author:** ![eggman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/51bf81/32.png) [@eggman2001](https://www.ruby-forum.com/u/eggman2001)\
**Post date:** [October 19, 2007, 5:26pm UTC](https://www.ruby-forum.com/t/debugging-question/117571/5 "2007-10-19T17:26:45Z")

</div>

I tried that, but it doesn’t work.

Here’s the error that I’m getting…  
C:\InstantRails\ruby\_progs\rdig\_testing\>rdeb  
s\rdig\_testing\config.rb  
C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/  
6:in `initialize': Bad file descriptor - con from C:/InstantRails/ruby/lib/ruby/g by-debug.rb:86:in`new’  
from C:/InstantRails/ruby/lib/ruby/g  
by-debug.rb:86:in `start\_client’  
from C:/InstantRails/ruby/lib/ruby/g  
ebug:87  
from C:/InstantRails/ruby/bin/rdebug  
from C:/InstantRails/ruby/bin/rdebug

C:\InstantRails\ruby\_progs\rdig\_testing\>

---

<div class="post-metadata">

**Author:** ![eggman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/51bf81/32.png) [@eggman2001](https://www.ruby-forum.com/u/eggman2001)\
**Post date:** [October 19, 2007, 5:29pm UTC](https://www.ruby-forum.com/t/debugging-question/117571/6 "2007-10-19T17:29:04Z")

</div>

checkout the topmost file line.  
Maybe you’re trying to run something on a port in use?

eggman2001 wrote:

> I tried that, but it doesn’t work.
> 
> Here’s the error that I’m getting…  
> C:\InstantRails\ruby\_progs\rdig\_testing\>rdeb  
> s\rdig\_testing\config.rb  
> C:/InstantRails/ruby/lib/ruby/gems/1.8/gems/  
> 6:in `initialize': Bad file descriptor - con from C:/InstantRails/ruby/lib/ruby/g by-debug.rb:86:in`new’  
> from C:/InstantRails/ruby/lib/ruby/g  
> by-debug.rb:86:in `start\_client’  
> from C:/InstantRails/ruby/lib/ruby/g  
> ebug:87  
> from C:/InstantRails/ruby/bin/rdebug  
> from C:/InstantRails/ruby/bin/rdebug
> 
> C:\InstantRails\ruby\_progs\rdig\_testing\>

---

<div class="post-metadata">

**Author:** ![eggman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/51bf81/32.png) [@eggman2001](https://www.ruby-forum.com/u/eggman2001)\
**Post date:** [October 20, 2007, 6:07pm UTC](https://www.ruby-forum.com/t/debugging-question/117571/7 "2007-10-20T18:07:56Z")

</div>

eggman2001 wrote:

> Not quite sure what you mean - sorry. I know very little about the  
> role that ports play in these situations.

go into the rdig file (find it), then add  
require ‘ruby-debug’  
debugger

and it should open a breakpoint for you there (run it normal).  
GL!  
-Roger

---

<div class="post-metadata">

**Author:** ![eggman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/51bf81/32.png) [@eggman2001](https://www.ruby-forum.com/u/eggman2001)\
**Post date:** [October 21, 2007, 1:50am UTC](https://www.ruby-forum.com/t/debugging-question/117571/8 "2007-10-21T01:50:14Z")

</div>

That worked! Thanks so much 🙂

---

<div class="post-metadata">

**Author:** ![eggman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/51bf81/32.png) [@eggman2001](https://www.ruby-forum.com/u/eggman2001)\
**Post date:** [October 20, 2007, 1:35am UTC](https://www.ruby-forum.com/t/debugging-question/117571/9 "2007-10-20T01:35:50Z")

</div>

Not quite sure what you mean - sorry. I know very little about the  
role that ports play in these situations.
