I have a function that looks like this:
def search_street_addresses(query, limit: 100)
if query.is_a? String
query = @address_parser.parse(query)
fail ArgumentError, "Invalid address string" if query.nil?
end
# ...
And it's called like this:
begin
results = @ndi.search_street_addresses(query)
rescue ArgumentError
raise CommandError, "Failed to parse address"
end
It works perfectly on my machine. I have stepped through the code with a debugger, and everything works as expected. The problem is that on the machine of a co-worker (with the exact same code as I and the exact same Ruby version) a seemingly impossible thing happens. Between the call @ndi.search_street_addresses(query)
and the first line of the function, an ArgumentError
is raised. I have inserted a breakpoint like this:
begin
require "byebug"; byebug
results = @ndi.search_street_addresses(query)
# ...
And attempted to step into the function, but the ArgumentError
is raised after the first step
I take, without me ever entering the function. I have also set a breakpoint in the function:
def search_street_addresses(query, limit: 100)
require "byebug"; byebug
if query.is_a? String
# ...
But the ArgumentError
is raised without the breakpoint triggering. This only happens on his machine, everything works perfectly on mine. I don't have the slightest clue how to debug this since the ArgumentError
is seemingly raised somewhere in the Ruby ether outside the reach of Byebug.
So; how do I debug this?
Anticlimactic answer; my co-worker reinstalled Ruby and now everything works. I'm not sure whether to delete this question or leave this answer to perhaps save a couple of hours of pointless debugging for somebody else.