# Local Variables vs. Instance Variables inside breakpointer

**URL:** <https://www.ruby-forum.com/t/local-variables-vs-instance-variables-inside-breakpointer/70792>\
**Category:** Rails\
**Created:** [October 3, 2006, 1:10am UTC](https://www.ruby-forum.com/t/local-variables-vs-instance-variables-inside-breakpointer/70792 "2006-10-03T01:10:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [October 3, 2006, 1:10am UTC](https://www.ruby-forum.com/t/local-variables-vs-instance-variables-inside-breakpointer/70792/1 "2006-10-03T01:10:19Z")

</div>

Hi,

I have a quick question about breakpoints. I am testing a class method  
inside a model in development mode and when I get to the breakpoint, I  
can’t seem to inspect any of the local variables inside the method.  
Here is what the code looks like:

class User  
self.register(params,options)  
@user = User.new(params[:user])  
user = User.new(params[:user])  
if options  
# do stuff  
breakpoint  
else  
# do other stuff  
end  
end  
end

I can inspect the instance variable just fine, but  
if I try to inspect the ‘user’ local variable or params or options I  
get the following exception:  
ameError: undefined local variable or method `user' for User:Class from (druby://localhost:42531) /opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:1129:in`method\_missing’  
from (druby://localhost:42531) (irb):1:in `breakpoint’

I noticed the same thing happens in unit tests as well. Any ideas?

I am using rails 1.1.6 and ruby 1.8.5

Thanks,  
Curtis

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [October 3, 2006, 2:14am UTC](https://www.ruby-forum.com/t/local-variables-vs-instance-variables-inside-breakpointer/70792/2 "2006-10-03T02:14:23Z")

</div>

I worked around this by upgrading to using ruby-debug within my rails  
app. It’s quite nice for someone who likes gdb! Still wondering why  
breakpoint didn’t happen to work otherwise though.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [November 9, 2006, 5:15pm UTC](https://www.ruby-forum.com/t/local-variables-vs-instance-variables-inside-breakpointer/70792/3 "2006-11-09T17:15:20Z")

</div>

I am experiencing the same issue as you, I can see instance but not  
local variables. However, it only acts this way on two different  
machines. On one machine with Rails installed via the Gem install I CAN  
see local variables but on another machine with a Rails install done  
via the SysAdmin(s) I can NOT see local variables (one could almost  
imagine the situation being reversed - a custom install of Rails  
_would_ have local variable visibility because it might be the version  
you ended up using - ruby-debug). But this isnt the case.

Did you make any further progress on this w/o having to resort to  
ruby-debug?

thanks.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [November 9, 2006, 6:43pm UTC](https://www.ruby-forum.com/t/local-variables-vs-instance-variables-inside-breakpointer/70792/4 "2006-11-09T18:43:44Z")

</div>

On Thursday 09 November 2006 17:14, Wiliam Langshaw wrote:

> Did you make any further progress on this w/o having to resort to  
> ruby-debug?

breakpoint(er) relies on Binding.of\_caller which was broken by Ruby  
1.8.5. Without this method, there’s no (easy, fast) way to access the  
local variables of the caller.

Michael

–  
Michael S.  
[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[http://www.schuerig.de/michael/](http://www.schuerig.de/michael/)
