diff options
author | Takashi Kokubun <[email protected]> | 2022-11-28 10:42:54 -0800 |
---|---|---|
committer | git <[email protected]> | 2022-11-28 18:42:59 +0000 |
commit | c5279db75f3e00b5c7df4d16bc38f6446f394260 (patch) | |
tree | 650fa5695b8b13bc2d6f480a078752c3753d55ca | |
parent | f3ad68dd161da60bb4f4908974839bb2b5736a85 (diff) |
[ruby/irb] Fix the debug.gem force-loader for Ruby 3.2
(https://github.com/ruby/irb/pull/458)
* Fix the debug.gem force-loader for Ruby 3.2
* Support 1.7.0dev format as well
-rw-r--r-- | lib/irb/cmd/debug.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/irb/cmd/debug.rb b/lib/irb/cmd/debug.rb index 9e2c096107..2c09c99cf0 100644 --- a/lib/irb/cmd/debug.rb +++ b/lib/irb/cmd/debug.rb @@ -82,14 +82,22 @@ module IRB # it's a bundled gem. This method tries to activate and load that. def load_bundled_debug_gem # Discover latest debug.gem under GEM_PATH - debug_gem = Gem.paths.path.map { |path| Dir.glob("#{path}/gems/debug-*") }.flatten.select do |path| - File.basename(path).match?(/\Adebug-\d+\.\d+\.\d+\z/) + debug_gem = Gem.paths.path.flat_map { |path| Dir.glob("#{path}/gems/debug-*") }.select do |path| + File.basename(path).match?(/\Adebug-\d+\.\d+\.\d+(\w+)?\z/) end.sort_by do |path| Gem::Version.new(File.basename(path).delete_prefix('debug-')) end.last return false unless debug_gem + # Discover debug/debug.so under extensions for Ruby 3.2+ + debug_so = Gem.paths.path.flat_map do |path| + Dir.glob("#{path}/extensions/**/#{File.basename(debug_gem)}/debug/debug.so") + end.first + # Attempt to forcibly load the bundled gem + if debug_so + $LOAD_PATH << debug_so.delete_suffix('/debug/debug.so') + end $LOAD_PATH << "#{debug_gem}/lib" begin require "debug/session" |