Skip to content

Commit

Permalink
Respect DLEXT to force-load debug.so (#481)
Browse files Browse the repository at this point in the history
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
  • Loading branch information
k0kubun and nobu authored Dec 20, 2022
1 parent dbb3dc7 commit 9d82778
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/irb/cmd/debug.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,14 @@ def load_bundled_debug_gem
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")
ext_name = "/debug/debug.#{RbConfig::CONFIG['DLEXT']}"
ext_path = Gem.paths.path.flat_map do |path|
Dir.glob("#{path}/extensions/**/#{File.basename(debug_gem)}#{ext_name}")
end.first

# Attempt to forcibly load the bundled gem
if debug_so
$LOAD_PATH << debug_so.delete_suffix('/debug/debug.so')
if ext_path
$LOAD_PATH << ext_path.delete_suffix(ext_name)
end
$LOAD_PATH << "#{debug_gem}/lib"
begin
Expand Down

0 comments on commit 9d82778

Please sign in to comment.