# Inexplicable "undefined local variable" error\`

**URL:** <https://www.ruby-forum.com/t/inexplicable-undefined-local-variable-error/167284>\
**Category:** Ruby\
**Created:** [May 6, 2009, 12:20pm UTC](https://www.ruby-forum.com/t/inexplicable-undefined-local-variable-error/167284 "2009-05-06T12:20:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbcox23](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/b9bd4f/32.png) [@tbcox23](https://www.ruby-forum.com/u/tbcox23)\
**Post date:** [May 6, 2009, 12:20pm UTC](https://www.ruby-forum.com/t/inexplicable-undefined-local-variable-error/167284/1 "2009-05-06T12:20:11Z")

</div>

This makes no sense to me, so…I could use a little help

In my main program I read in some ruby from an external file:

eval( File.read( “…/lib/setnet/Utilities.rb” ) )

I check a variable which should now be defined (by a line in that file),  
using ruby-debug:

Breakpoint 1 at SN.rb:550  
…/lib/setnet/SN.rb:550  
pp menu\_ut # \<= my main program code about to execute, so menu\_ut  
better be there  
(rdb:1) p defined? menu\_ut  
“local-variable” # \<= looks good  
(rdb:1) p menu\_ut # \<= this successfully prints the expected contents  
of this array.  
[…]  
(rdb:1) c # now the above line of program code should execute without  
error…and we get instead…

…/lib/setnet/SN.rb:550:in `proc_command': undefined local variable or method`menu\_ut’ for #SN::SetNet:0xb79adac8 (NameError)

…and it blows.

How can this be?

I do know that if I make this variable a constant, in the input file,  
all is well. But I had thought an ordinary variable would be fine, as  
the input code is evaluated in the current binding…only it doesn’t  
seem to be there (the variable), unless you ask ruby-debug, which says  
it is.

I cannot make sense of this. And…I need to fix it somehow.

All suggestions most welcome.

Tom
