Your environment
ruby -v: ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x86_64-linux]
rdbg -v: rdbg 1.4.0
Describe the bug
I decided to try out the new debug gem bundled with ruby 3.1.0, but it looks like I did too much black magic with how I load my code and it broke. I'm not 100% sure this is valid usage of this gem though, so feel free to close this issue if it is invalid.
To Reproduce
I have two files, a.rb:
require 'debug'
def foo; binding.debugger; end
and b.rb:
eval File.read('a.rb'), binding, 'a.rb'
foo
Running ruby b.rb, I get:
# No sourcefile available for a.rb
=>#0 Object#foo at a.rb:2
#1 <main> at b.rb:2
If I require debug in b.rb, it works. If I use require_relative 'a' instead of File.read+eval, it works. If I require debug in a separate eval in b.rb, it also works. So does ruby -rdebug b.rb, and rdbg b.rb, obviously.
Expected behavior
It should display the source properly:
[1, 2] in a.rb
1| require 'debug'
=> 2| def foo; binding.debugger; end
Additional context
Sorry.