summaryrefslogtreecommitdiff
path: root/lib/rubygems.rb
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2020-03-25 15:55:16 +0100
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-06-05 07:32:42 +0900
commitf8f5e7fadf689a11a8ee28b7af4e7777e2dec1ea (patch)
tree2c8c7e793df0504e93e714a105ad2f5d27463708 /lib/rubygems.rb
parentff5ca548c3540c5a98a3851248248de117b2bf2f (diff)
[rubygems/rubygems] Respect files loaded from default gems before rubygems
https://github.com/rubygems/rubygems/commit/f3da3c1190
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3184
Diffstat (limited to 'lib/rubygems.rb')
-rw-r--r--lib/rubygems.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index b03d747..ca80326 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -1226,6 +1226,8 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
next unless $~
end
+ spec.activate if already_loaded?(file)
+
@path_to_default_spec_map[file] = spec
@path_to_default_spec_map[file.sub(suffix_regexp, "")] = spec
end
@@ -1291,6 +1293,18 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
attr_reader :pre_uninstall_hooks
+ private
+
+ def already_loaded?(file)
+ default_gem_load_paths.find do |load_path_entry|
+ $LOADED_FEATURES.include?("#{load_path_entry}/#{file}")
+ end
+ end
+
+ def default_gem_load_paths
+ @default_gem_load_paths ||= $LOAD_PATH[load_path_insert_index..-1]
+ end
+
end
##