Skip to content

Commit 1c48aa6

Browse files
deivid-rodriguezhsbt
authored andcommitted
[rubygems/rubygems] Move loading Bundler without platform warnings to a method
ruby/rubygems@e068f0649a
1 parent 4651d23 commit 1c48aa6

File tree

2 files changed

+29
-24
lines changed

2 files changed

+29
-24
lines changed

lib/rubygems.rb

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,34 @@ def self.load_safe_marshal
636636
@safe_marshal_loaded = true
637637
end
638638

639+
##
640+
# Load Bundler, making sure to avoid redefinition warnings in platform
641+
# constants
642+
643+
def self.load_bundler
644+
require "bundler/version"
645+
646+
if Bundler::VERSION > "2.6.9"
647+
require "bundler"
648+
else
649+
previous_platforms = {}
650+
651+
platform_const_list = ["JAVA", "MSWIN", "MSWIN64", "MINGW", "X64_MINGW_LEGACY", "X64_MINGW", "UNIVERSAL_MINGW", "WINDOWS", "X64_LINUX", "X64_LINUX_MUSL"]
652+
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
657+
658+
require "bundler"
659+
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
664+
end
665+
end
666+
639667
##
640668
# The file name and line number of the caller of the caller of this method.
641669
#
@@ -1144,7 +1172,7 @@ def self.use_gemdeps(path = nil)
11441172

11451173
ENV["BUNDLE_GEMFILE"] ||= File.expand_path(path)
11461174
require_relative "rubygems/user_interaction"
1147-
require_relative "rubygems/bundler_integration"
1175+
Gem.load_bundler
11481176
begin
11491177
Gem::DefaultUserInteraction.use_ui(ui) do
11501178
Bundler.ui.silence do

lib/rubygems/bundler_integration.rb

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)