# Need help invoking debug

**URL:** <https://www.ruby-forum.com/t/need-help-invoking-debug/177043>\
**Category:** Ruby\
**Created:** [October 10, 2009, 11:13am UTC](https://www.ruby-forum.com/t/need-help-invoking-debug/177043 "2009-10-10T11:13:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shawn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f6c823/32.png) [@shawn](https://www.ruby-forum.com/u/shawn)\
**Post date:** [October 10, 2009, 11:13am UTC](https://www.ruby-forum.com/t/need-help-invoking-debug/177043/1 "2009-10-10T11:13:39Z")

</div>

Newbie here… I’m trying to run a ruby program in debug mode. I used  
the following command:

ruby -r debug debugtest.rb

The response I get is this:

Debug.rb  
Emacs support available.

C:/Program Files/Ruby/lib/ruby/site\_ruby/1.8/ubygems.rb:10:require  
‘rubygems’  
(rdb:1)

No typos… does it have something to do with the reference to ubygems.  
I haven’t played around with the installation files so I don’t  
understand how a file could be mis-named, but who knows. And looking at  
the folder shows both rubygems.rb and ubygems.rb.

Or is it referring to something else? I don’t get it. I’m working my  
way through a beginners book but seem to be hung-up on this example.

Thanks in advance…

---

<div class="post-metadata">

**Author:** ![shawn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f6c823/32.png) [@shawn](https://www.ruby-forum.com/u/shawn)\
**Post date:** [October 10, 2009, 10:36pm UTC](https://www.ruby-forum.com/t/need-help-invoking-debug/177043/2 "2009-10-10T22:36:29Z")

</div>

On Sat, Oct 10, 2009 at 5:13 AM, Shawn H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> C:/Program Files/Ruby/lib/ruby/site\_ruby/1.8/ubygems.rb:10:require  
> ‘rubygems’  
> (rdb:1)
> 
> No typos… does it have something to do with the reference to ubygems.  
> I haven’t played around with the installation files so I don’t  
> understand how a file could be mis-named, but who knows. And looking at  
> the folder shows both rubygems.rb and ubygems.rb.
> 
> Or is it referring to something else? I don’t get it. I’m working my  
> way through a beginners book but seem to be hung-up on this example.

Did you try looking at what’s inside ubygems.rb

# This file allows for the running of rubygems with a nice

# command line look-and-feel: ruby -rubygems foo.rb

#–

# Copyright 2006 by Chad F., Rich Kilmer, Jim W. and others.

# All rights reserved.

# See LICENSE.txt for permissions.

#++

require ‘rubygems’

–  
Rick DeNatale

Blog: [http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)  
Twitter: [http://twitter.com/RickDeNatale](http://twitter.com/RickDeNatale)  
WWR: [http://www.workingwithrails.com/person/9021-rick-denatale](http://www.workingwithrails.com/person/9021-rick-denatale)  
LinkedIn: [http://www.linkedin.com/in/rickdenatale](http://www.linkedin.com/in/rickdenatale)

---

<div class="post-metadata">

**Author:** ![shawn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f6c823/32.png) [@shawn](https://www.ruby-forum.com/u/shawn)\
**Post date:** [October 10, 2009, 11:13pm UTC](https://www.ruby-forum.com/t/need-help-invoking-debug/177043/3 "2009-10-10T23:13:44Z")

</div>

> C:/Program Files/Ruby/lib/ruby/site\_ruby/1.8/ubygems.rb:10:require  
> ‘rubygems’  
> (rdb:1)
> 
> No typos… does it have something to do with the reference to ubygems.  
> I haven’t played around with the installation files so I don’t  
> understand how a file could be mis-named, but who knows. And looking at  
> the folder shows both rubygems.rb and ubygems.rb.

What’s happening is probably that you have RUBYOPT=-rubygems

which is a shortcut way to require rubygems, sometimes setup by the one  
click installer. So when you ruby ruby -r debug some\_file

it ends up running a require BEFORE it runs that file, and,  
conveniently, brings you to a debug prompt in the pre-file file.

To get around it:  
gem install ruby-debug  
then within debugtest.rb  
require ‘ruby-debug’  
debugger  
Cheers!  
-r

---

<div class="post-metadata">

**Author:** ![shawn](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f6c823/32.png) [@shawn](https://www.ruby-forum.com/u/shawn)\
**Post date:** [October 11, 2009, 12:13am UTC](https://www.ruby-forum.com/t/need-help-invoking-debug/177043/4 "2009-10-11T00:13:32Z")

</div>

> What’s happening is probably that you have RUBYOPT=-rubygems
> 
> which is a shortcut way to require rubygems, sometimes setup by the one  
> click installer. So when you ruby ruby -r debug some\_file
> 
> it ends up running a require BEFORE it runs that file, and,  
> conveniently, brings you to a debug prompt in the pre-file file.
> 
> To get around it:  
> gem install ruby-debug  
> then within debugtest.rb  
> require ‘ruby-debug’  
> debugger  
> Cheers!  
> -r

Thanks for the advice guys… RP I did what you suggested and it seemed  
to work, although some of the commands don’t seem to work (following the  
example in the book). But I was able to list and step through the  
code… maybe a different version of ruby-debug from that used in the  
book.

I’m moving on… I figure I can come back to this if it proves to be  
important when I have some more knowledge. Thanks again for the help.
