# Triggering the debugger II

**URL:** <https://www.ruby-forum.com/t/triggering-the-debugger-ii/191666>\
**Category:** Ruby\
**Created:** [July 16, 2010, 12:34am UTC](https://www.ruby-forum.com/t/triggering-the-debugger-ii/191666 "2010-07-16T00:34:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [July 16, 2010, 12:34am UTC](https://www.ruby-forum.com/t/triggering-the-debugger-ii/191666/1 "2010-07-16T00:34:04Z")

</div>

I’m still having trouble with the debugger and debugging

Here’s part of my source …

* * *

1. #!/usr/bin/env ruby
2. require ‘rubygems’
3. require ‘ruby-debug’
4. Debugger.start
5. 
6. debugger

* * *

Here’s my session

* * *

f:\UltraDedup\>ruby -rdebug UltraDedup.rb  
Debug.rb  
Emacs support available.

UltraDedup.rb:2:require ‘rubygems’  
(rdb:1) b 3  
Set breakpoint 1 at UltraDedup.rb:3  
(rdb:1) b 4  
Set breakpoint 2 at UltraDedup.rb:4  
(rdb:1) b 6  
Set breakpoint 3 at UltraDedup.rb:6  
(rdb:1) c  
F:/InstantRails-2.0-win/ruby/lib/ruby/1.8/rational.rb:78: `undefined method`gcd’ for Rational(1, 2):Rational’ (NoMethodError)  
from  
F:/InstantRails-2.0-win/ruby/lib/ruby/site\_ruby/1.8/rubygems/config\_file.rb:220:in  
`load_file' from F:/InstantRails-2.0-win/ruby/lib/ruby/site_ruby/1.8/rubygems/config_file.rb:168:in`initialize’  
from  
F:/InstantRails-2.0-win/ruby/lib/ruby/site\_ruby/1.8/rubygems.rb:384:in  
`new' from F:/InstantRails-2.0-win/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:384:in`configuration’  
from  
F:/InstantRails-2.0-win/ruby/lib/ruby/site\_ruby/1.8/rubygems.rb:634:in  
`path' from F:/InstantRails-2.0-win/ruby/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:68:in`installed\_spec\_directories’  
from  
F:/InstantRails-2.0-win/ruby/lib/ruby/site\_ruby/1.8/rubygems/source\_index.rb:58:in  
`from_installed_gems' from F:/InstantRails-2.0-win/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:881:in`source\_index’  
from  
F:/InstantRails-2.0-win/ruby/lib/ruby/site\_ruby/1.8/rubygems/gem\_path\_searcher.rb:81:in  
`init_gemspecs' from F:/InstantRails-2.0-win/ruby/lib/ruby/site_ruby/1.8/rubygems/gem_path_searcher.rb:13:in`initialize’  
from  
F:/InstantRails-2.0-win/ruby/lib/ruby/site\_ruby/1.8/rubygems.rb:839:in  
`new' from F:/InstantRails-2.0-win/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:839:in`searcher’  
from  
F:/InstantRails-2.0-win/ruby/lib/ruby/site\_ruby/1.8/rubygems.rb:838:in  
`synchronize' from F:/InstantRails-2.0-win/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:838:in`searcher’  
from  
F:/InstantRails-2.0-win/ruby/lib/ruby/site\_ruby/1.8/rubygems.rb:478:in  
`find_files' from F:/InstantRails-2.0-win/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:1103 from UltraDedup.rb:2:in`require’  
from UltraDedup.rb:2  
F:/InstantRails-2.0-win/ruby/lib/ruby/1.8/rational.rb:78: gcd =  
num.gcd(den)  
(rdb:1) quit

* * *

As you can see … I either don’t stop where I think I’m stopping or I  
am getting this strange stack before I hit line 3.

Any thoughts???

Damn … I don’t have this problem in an Instant Rails environment.

I am using Instant Rails to develope a Ruby/FXRuby program. Is that a  
no-no?

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [July 16, 2010, 1:10pm UTC](https://www.ruby-forum.com/t/triggering-the-debugger-ii/191666/2 "2010-07-16T13:10:24Z")

</div>

ruby -rdebug UltraDedup.rb

invokes the debugger that comes with Ruby, not ruby-debug. To invoke  
ruby-debug run as rdebug.

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [July 16, 2010, 2:14pm UTC](https://www.ruby-forum.com/t/triggering-the-debugger-ii/191666/3 "2010-07-16T14:14:50Z")

</div>

Rocky,

Friday, July 16, 2010, 5:10:04 AM, you wrote:

r\> ruby -rdebug UltraDedup.rb

r\> invokes the debugger that comes with Ruby, not ruby-debug. To invoke  
ruby-debug run as rdebug.

May the gods smile on your house and your family.

Rocky, what does ruby-debug do that the native debugger does not?

I’m not groking this at all.

Ralph

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [July 16, 2010, 4:41pm UTC](https://www.ruby-forum.com/t/triggering-the-debugger-ii/191666/4 "2010-07-16T16:41:55Z")

</div>

> Rocky, what does ruby-debug do that the native debugger does not?

Faster, less bugs.

Also, if you want to stop where you exception is thrown I believe you  
can run

rdebug:1 \> catch Exception

and it will stop after it’s thrown.

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [July 17, 2010, 1:25am UTC](https://www.ruby-forum.com/t/triggering-the-debugger-ii/191666/5 "2010-07-17T01:25:45Z")

</div>

> It’s unfortunate that the 2 different debuggers both use the word  
> rdebug somehow in their invocation… With the original debug.rb, you  
> start debugging your program via ‘ruby -rdebug’ whereas with  
> ruby-debug gem, you start debugging via ‘rdebug’. This makes it more  
> confusing than it ought to be.

With ruby-debug, I start debugging via the “debugger” method in my  
code, possibly conditional, in the exact place I want it. Couldn’t be  
happier!

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [July 16, 2010, 6:41pm UTC](https://www.ruby-forum.com/t/triggering-the-debugger-ii/191666/6 "2010-07-16T18:41:17Z")

</div>

On 7/16/10, rocky \<[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)/\> wrote:

> ruby -rdebug UltraDedup.rb
> 
> invokes the debugger that comes with Ruby, not ruby-debug. To invoke  
> ruby-debug run as rdebug.

Furthermore, if you run your ruby program via the rdebug command, you  
needn’t modify your source code at all.

It’s unfortunate that the 2 different debuggers both use the word  
rdebug somehow in their invocation… With the original debug.rb, you  
start debugging your program via ‘ruby -rdebug’ whereas with  
ruby-debug gem, you start debugging via ‘rdebug’. This makes it more  
confusing than it ought to be.

---

<div class="post-metadata">

**Author:** ![ralphshnelvar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ralphshnelvar](https://www.ruby-forum.com/u/ralphshnelvar)\
**Post date:** [July 17, 2010, 11:05pm UTC](https://www.ruby-forum.com/t/triggering-the-debugger-ii/191666/7 "2010-07-17T23:05:42Z")

</div>

On Jul 16, 12:40 pm, Caleb C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> It’s unfortunate that the 2 different debuggers both use the word  
> rdebug somehow in their invocation… With the original debug.rb, you  
> start debugging your program via ‘ruby -rdebug’ whereas withruby-debuggem, you start debugging via ‘rdebug’. This makes it more  
> confusing than it ought to be.

Yes, it rdebug was an unfortunate name. In the rewrite [1], I don’t  
make that mistake. However currently that debugger is called rbdbgr  
which I have come to learn that that is a very very bad name for the  
project. I need to change that eventually – different mistakes!

With regards to the question to the differences between debug.rb and  
ruby-debug, others have answered this very nicely. Thanks! And there  
is Pascal’s blog on this from a while ago [2].

Nevertheless I’ll try to summarize differences and note the possible  
confusion on the next update of “Debugging with ruby-debug” [3].

[1] [http://github.com/rocky/rbdbgr](http://github.com/rocky/rbdbgr)  
[2]  
[http://blog.nanorails.com/articles/2006/07/14/a-better-rails-debugger-ruby-debug/](http://blog.nanorails.com/articles/2006/07/14/a-better-rails-debugger-ruby-debug/)  
[3] [http://bashdb.sourceforge.net/ruby-debug.html](http://bashdb.sourceforge.net/ruby-debug.html)
