Skip to content

Commit e068f06

Browse files
Move loading Bundler without platform warnings to a method
1 parent d9acc80 commit e068f06

File tree

3 files changed

+29
-25
lines changed

3 files changed

+29
-25
lines changed

Manifest.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,6 @@ hide_lib_for_update/note.txt
366366
lib/rubygems.rb
367367
lib/rubygems/available_set.rb
368368
lib/rubygems/basic_specification.rb
369-
lib/rubygems/bundler_integration.rb
370369
lib/rubygems/bundler_version_finder.rb
371370
lib/rubygems/ci_detector.rb
372371
lib/rubygems/command.rb

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)