Skip to content

Commit 9e7018b

Browse files
Change helper to load only Bundler extensions to RubyGems
We'll want to reuse this helper in other situations where we don't want all Bundler loaded.
1 parent e068f06 commit 9e7018b

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

lib/rubygems.rb

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -637,30 +637,27 @@ def self.load_safe_marshal
637637
end
638638

639639
##
640-
# Load Bundler, making sure to avoid redefinition warnings in platform
641-
# constants
640+
# Load Bundler extensions to RubyGems, making sure to avoid redefinition
641+
# warnings in platform constants
642642

643-
def self.load_bundler
643+
def self.load_bundler_extensions
644644
require "bundler/version"
645+
return if Bundler::VERSION >= "2.6.9"
645646

646-
if Bundler::VERSION > "2.6.9"
647-
require "bundler"
648-
else
649-
previous_platforms = {}
647+
previous_platforms = {}
650648

651-
platform_const_list = ["JAVA", "MSWIN", "MSWIN64", "MINGW", "X64_MINGW_LEGACY", "X64_MINGW", "UNIVERSAL_MINGW", "WINDOWS", "X64_LINUX", "X64_LINUX_MUSL"]
649+
platform_const_list = ["JAVA", "MSWIN", "MSWIN64", "MINGW", "X64_MINGW_LEGACY", "X64_MINGW", "UNIVERSAL_MINGW", "WINDOWS", "X64_LINUX", "X64_LINUX_MUSL"]
652650

653-
platform_const_list.each do |platform|
654-
previous_platforms[platform] = Gem::Platform.const_get(platform)
655-
Gem::Platform.send(:remove_const, platform)
656-
end
651+
platform_const_list.each do |platform|
652+
previous_platforms[platform] = Gem::Platform.const_get(platform)
653+
Gem::Platform.send(:remove_const, platform)
654+
end
657655

658-
require "bundler"
656+
require "bundler/rubygems_ext"
659657

660-
platform_const_list.each do |platform|
661-
Gem::Platform.send(:remove_const, platform) if Gem::Platform.const_defined?(platform)
662-
Gem::Platform.const_set(platform, previous_platforms[platform])
663-
end
658+
platform_const_list.each do |platform|
659+
Gem::Platform.send(:remove_const, platform) if Gem::Platform.const_defined?(platform)
660+
Gem::Platform.const_set(platform, previous_platforms[platform])
664661
end
665662
end
666663

@@ -1172,7 +1169,8 @@ def self.use_gemdeps(path = nil)
11721169

11731170
ENV["BUNDLE_GEMFILE"] ||= File.expand_path(path)
11741171
require_relative "rubygems/user_interaction"
1175-
Gem.load_bundler
1172+
Gem.load_bundler_extensions
1173+
require "bundler"
11761174
begin
11771175
Gem::DefaultUserInteraction.use_ui(ui) do
11781176
Bundler.ui.silence do

0 commit comments

Comments
 (0)