Bizarre ruby debug behaviour when using variables beginning with character 'u' on windows


#1

I’m using Instant Rails on windows. I’m also using ruby debug.

I first stumbled across the problem when an array that I named
utilities_used = [] was misbehaving. I added some experimental code
and set a breakpoint and started to investigate.

Here’s my code (it’s inside a model file):

foo = []
ufoo = []
vfoo = []
utfoo = []
utifoo = []
utils = []
utils_foo = []
foo_used = []
utils_used = []
missing_vehicles = []

debugger

When I break into the debugger:
(rdb:94) foo
[ ]
(rdb:94) vfoo
[ ]
(rdb:94) foo_used
[ ]
(rdb:94) missing_vehicles
[ ]
(rdb:94) ufoo
#1 E:/InstantRails-2.0-win/rails_apps/Carbon Salon Source Tree/app/
controllers/admin_controller.rb:37 in ‘receive_file’
(rdb:94) foo
NameError Exception: undefined local variable or method foo' for #<AdminController:0x46b45b4> (rdb:94) vfoo NameError Exception: undefined local variable or methodvfoo’ for
#AdminController:0x46b45b4
(rdb:94) foo_used
NameError Exception: undefined local variable or method foo_used' for #<AdminController:0x46b45b4> (rdb:94) missing_vehicles NameError Exception: undefined local variable or methodmissing_vehicles’ for #AdminController:0x46b45b4

Note that, as soon as I inspect an array who’s name starts with the
letter ‘u’, everything goes to pot…

I tinkered with this some more:
Code:
foo = [‘a’, ‘b’, ‘c’]
ufoo = [‘d’, ‘e’, ‘f’]
missing_vehicles = []

foo.each {|f| puts f}
ufoo.each {|u| puts u}

Console output:
Processing AdminController#receive_file (for 127.0.0.1 at 2008-11-10
16:58:09) [POST]
Session ID: 858773c8b3335d4c6e9a1326e17c7cd0
Parameters: {“user_data_file”=>#<ActionController::UploadedStringIO:
0x42920a8>, “action”=>“receive_file”, “authenticity_token”=>“8
ce751d807f83817a140eb1cc4e463cc8f5b20f0”, “controller”=>“admin”}
a
b
c
d
e
f
E:/InstantRails-2.0-win/rails_apps/Carbon Salon Source Tree/app/models/
user_data_file.rb:95 #end

so - the code itself seems to work, back to the debugger:

(rdb:98) foo
[“a”, “b”, “c”]
(rdb:98) ufoo
#1 E:/InstantRails-2.0-win/rails_apps/Carbon Salon Source Tree/app/
controllers/admin_controller.rb:37 in ‘receive_file’
(rdb:98) foo
NameError Exception: undefined local variable or method `foo’ for
#AdminController:0x426b46c
(rdb:98)

So - it seems to be a problem with the debugger, rather than with
ruby. In fact, now that I think of it, i’ve repeatedly experienced
bizarre behaviour when using the debugger to inspect variables that
begin with the letter ‘u’. Anybody else seen this?

I’m new to RoR, so - maybe i’m doing something stupid here… any
input, enlightenment would be very much appreciated.

Yoram


#2

On 11 Nov 2008, at 01:04, removed_email_address@domain.invalid wrote:

ufoo = []

#1 E:/InstantRails-2.0-win/rails_apps/Carbon Salon Source Tree/app/
controllers/admin_controller.rb:37 in ‘receive_file’

Looks like ruby debug sees the u and handles it like the u command
(which means move up the stack frame, pushing all your local variables
out of scope). I’m surprised any of this works - normally to evaluate
an expression you need to use the e command ie
e foo

Fred