summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJean Boussier <[email protected]>2024-07-22 15:39:17 +0200
committerJean Boussier <[email protected]>2024-07-22 18:07:18 +0200
commit34adc07372c10170b8ca36111d216cbd8e4699be (patch)
tree18d6d6455ecbc7251a91f2681c1ce0c6cace7054 /lib
parent5e3b8010ed5a26b364376730a154bb3f25b3bb98 (diff)
Document the reasoning behind the fix for [Bug #20641]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/11219
Diffstat (limited to 'lib')
-rw-r--r--lib/bundled_gems.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/bundled_gems.rb b/lib/bundled_gems.rb
index a42b12ac23..9d6e01141a 100644
--- a/lib/bundled_gems.rb
+++ b/lib/bundled_gems.rb
@@ -95,7 +95,16 @@ module Gem::BUNDLED_GEMS
# name can be a feature name or a file path with String or Pathname
feature = File.path(name)
+ # The actual checks needed to properly identify the gem being required
+ # are costly (see [Bug #20641]), so we first do a much cheaper check
+ # to exclude the vast majority of candidates.
if feature.include?("/")
+ # If requiring $LIBDIR/mutex_m.rb, we check SINCE_FAST_PATH["mutex_m"]
+ # We'll fail to warn requires for files that are not the entry point
+ # of the gem, e.g. require "logger/formatter.rb" won't warn.
+ # But that's acceptable because this warning is best effort,
+ # and in the overwhelming majority of cases logger.rb will end
+ # up required.
return unless SINCE_FAST_PATH[File.basename(feature, ".*")]
else
return unless SINCE_FAST_PATH[feature]