diff options
author | David RodrÃguez <[email protected]> | 2025-06-11 17:58:35 +0200 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2025-06-16 10:03:36 +0900 |
commit | ddb412f6804484db165fdbbd34e144a7b2bed5b0 (patch) | |
tree | 3d8e70c625c59327a027a80e169d16458e001a86 /lib | |
parent | 022c18b60d2245980abcdd7b5195eebca73b8809 (diff) |
[rubygems/rubygems] Fix redefinition warnings when using modern RubyGems with old Bundler
https://github.com/rubygems/rubygems/commit/ce7e8e92ca
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rubygems.rb | 2 | ||||
-rw-r--r-- | lib/rubygems/bundler_integration.rb | 23 |
2 files changed, 24 insertions, 1 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb index 1225cbe5cb..fc97f5ff25 100644 --- a/lib/rubygems.rb +++ b/lib/rubygems.rb @@ -1144,7 +1144,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]} ENV["BUNDLE_GEMFILE"] ||= File.expand_path(path) require_relative "rubygems/user_interaction" - require "bundler" + require_relative "rubygems/bundler_integration" begin Gem::DefaultUserInteraction.use_ui(ui) do Bundler.ui.silence do diff --git a/lib/rubygems/bundler_integration.rb b/lib/rubygems/bundler_integration.rb new file mode 100644 index 0000000000..28228e2398 --- /dev/null +++ b/lib/rubygems/bundler_integration.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require "bundler/version" + +if Bundler::VERSION > "2.6.9" + require "bundler" +else + previous_platforms = {} + + platform_const_list = ["JAVA", "MSWIN", "MSWIN64", "MINGW", "X64_MINGW_LEGACY", "X64_MINGW", "UNIVERSAL_MINGW", "WINDOWS", "X64_LINUX", "X64_LINUX_MUSL"] + + platform_const_list.each do |platform| + previous_platforms[platform] = Gem::Platform.const_get(platform) + Gem::Platform.send(:remove_const, platform) + end + + require "bundler" + + platform_const_list.each do |platform| + Gem::Platform.send(:remove_const, platform) if Gem::Platform.const_defined?(platform) + Gem::Platform.const_set(platform, previous_platforms[platform]) + end +end |