summaryrefslogtreecommitdiff
path: root/lib/rubygems/bundler_integration.rb
blob: 28228e2398801b5e4d02693c19bf37e3dce00108 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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