bundler 2.3.12 → 2.4.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (226) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +367 -1
  3. data/README.md +2 -2
  4. data/bundler.gemspec +8 -10
  5. data/exe/bundle +1 -4
  6. data/lib/bundler/build_metadata.rb +2 -2
  7. data/lib/bundler/cli/add.rb +1 -1
  8. data/lib/bundler/cli/binstubs.rb +5 -1
  9. data/lib/bundler/cli/check.rb +1 -1
  10. data/lib/bundler/cli/common.rb +3 -1
  11. data/lib/bundler/cli/console.rb +2 -2
  12. data/lib/bundler/cli/doctor.rb +4 -6
  13. data/lib/bundler/cli/gem.rb +62 -40
  14. data/lib/bundler/cli/init.rb +5 -1
  15. data/lib/bundler/cli/install.rb +7 -5
  16. data/lib/bundler/cli/lock.rb +8 -5
  17. data/lib/bundler/cli/open.rb +6 -4
  18. data/lib/bundler/cli/outdated.rb +13 -6
  19. data/lib/bundler/cli/platform.rb +1 -1
  20. data/lib/bundler/cli/viz.rb +1 -1
  21. data/lib/bundler/cli.rb +52 -7
  22. data/lib/bundler/compact_index_client/cache.rb +1 -1
  23. data/lib/bundler/compact_index_client/updater.rb +53 -39
  24. data/lib/bundler/constants.rb +1 -1
  25. data/lib/bundler/current_ruby.rb +15 -6
  26. data/lib/bundler/definition.rb +203 -110
  27. data/lib/bundler/dependency.rb +21 -84
  28. data/lib/bundler/digest.rb +1 -1
  29. data/lib/bundler/dsl.rb +13 -18
  30. data/lib/bundler/endpoint_specification.rb +6 -10
  31. data/lib/bundler/env.rb +1 -1
  32. data/lib/bundler/environment_preserver.rb +1 -0
  33. data/lib/bundler/errors.rb +15 -15
  34. data/lib/bundler/feature_flag.rb +0 -1
  35. data/lib/bundler/fetcher/base.rb +6 -8
  36. data/lib/bundler/fetcher/compact_index.rb +9 -11
  37. data/lib/bundler/fetcher/dependency.rb +1 -1
  38. data/lib/bundler/fetcher/downloader.rb +2 -5
  39. data/lib/bundler/fetcher.rb +12 -12
  40. data/lib/bundler/force_platform.rb +18 -0
  41. data/lib/bundler/friendly_errors.rb +21 -7
  42. data/lib/bundler/gem_helpers.rb +9 -2
  43. data/lib/bundler/gem_version_promoter.rb +53 -98
  44. data/lib/bundler/graph.rb +3 -3
  45. data/lib/bundler/index.rb +11 -49
  46. data/lib/bundler/injector.rb +8 -3
  47. data/lib/bundler/inline.rb +9 -21
  48. data/lib/bundler/installer/gem_installer.rb +14 -1
  49. data/lib/bundler/installer/parallel_installer.rb +0 -31
  50. data/lib/bundler/installer/standalone.rb +41 -10
  51. data/lib/bundler/installer.rb +18 -39
  52. data/lib/bundler/lazy_specification.rb +53 -48
  53. data/lib/bundler/lockfile_generator.rb +1 -1
  54. data/lib/bundler/lockfile_parser.rb +9 -5
  55. data/lib/bundler/man/bundle-add.1 +13 -5
  56. data/lib/bundler/man/bundle-add.1.ronn +10 -4
  57. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  58. data/lib/bundler/man/bundle-cache.1 +7 -1
  59. data/lib/bundler/man/bundle-cache.1.ronn +7 -0
  60. data/lib/bundler/man/bundle-check.1 +1 -1
  61. data/lib/bundler/man/bundle-clean.1 +2 -2
  62. data/lib/bundler/man/bundle-clean.1.ronn +1 -1
  63. data/lib/bundler/man/bundle-config.1 +26 -7
  64. data/lib/bundler/man/bundle-config.1.ronn +17 -7
  65. data/lib/bundler/man/bundle-console.1 +53 -0
  66. data/lib/bundler/man/bundle-console.1.ronn +44 -0
  67. data/lib/bundler/man/bundle-doctor.1 +1 -1
  68. data/lib/bundler/man/bundle-exec.1 +6 -6
  69. data/lib/bundler/man/bundle-exec.1.ronn +6 -6
  70. data/lib/bundler/man/bundle-gem.1 +27 -37
  71. data/lib/bundler/man/bundle-gem.1.ronn +5 -5
  72. data/lib/bundler/man/bundle-help.1 +13 -0
  73. data/lib/bundler/man/bundle-help.1.ronn +12 -0
  74. data/lib/bundler/man/bundle-info.1 +1 -1
  75. data/lib/bundler/man/bundle-init.1 +1 -1
  76. data/lib/bundler/man/bundle-inject.1 +5 -2
  77. data/lib/bundler/man/bundle-inject.1.ronn +3 -1
  78. data/lib/bundler/man/bundle-install.1 +5 -30
  79. data/lib/bundler/man/bundle-install.1.ronn +6 -29
  80. data/lib/bundler/man/bundle-list.1 +1 -1
  81. data/lib/bundler/man/bundle-lock.1 +1 -1
  82. data/lib/bundler/man/bundle-open.1 +22 -2
  83. data/lib/bundler/man/bundle-open.1.ronn +9 -1
  84. data/lib/bundler/man/bundle-outdated.1 +1 -1
  85. data/lib/bundler/man/bundle-platform.1 +16 -6
  86. data/lib/bundler/man/bundle-platform.1.ronn +14 -7
  87. data/lib/bundler/man/bundle-plugin.1 +81 -0
  88. data/lib/bundler/man/bundle-plugin.1.ronn +59 -0
  89. data/lib/bundler/man/bundle-pristine.1 +1 -1
  90. data/lib/bundler/man/bundle-remove.1 +1 -1
  91. data/lib/bundler/man/bundle-show.1 +1 -1
  92. data/lib/bundler/man/bundle-update.1 +1 -1
  93. data/lib/bundler/man/bundle-version.1 +35 -0
  94. data/lib/bundler/man/bundle-version.1.ronn +24 -0
  95. data/lib/bundler/man/bundle-viz.1 +4 -1
  96. data/lib/bundler/man/bundle-viz.1.ronn +2 -0
  97. data/lib/bundler/man/bundle.1 +15 -10
  98. data/lib/bundler/man/bundle.1.ronn +12 -7
  99. data/lib/bundler/man/gemfile.5 +92 -81
  100. data/lib/bundler/man/gemfile.5.ronn +98 -85
  101. data/lib/bundler/man/index.txt +4 -0
  102. data/lib/bundler/match_metadata.rb +13 -0
  103. data/lib/bundler/match_platform.rb +0 -1
  104. data/lib/bundler/match_remote_metadata.rb +29 -0
  105. data/lib/bundler/mirror.rb +5 -7
  106. data/lib/bundler/plugin/api/source.rb +3 -3
  107. data/lib/bundler/plugin/index.rb +4 -4
  108. data/lib/bundler/plugin/installer/git.rb +0 -4
  109. data/lib/bundler/plugin/installer/rubygems.rb +0 -8
  110. data/lib/bundler/plugin.rb +2 -0
  111. data/lib/bundler/process_lock.rb +1 -1
  112. data/lib/bundler/remote_specification.rb +8 -9
  113. data/lib/bundler/resolver/base.rb +77 -0
  114. data/lib/bundler/resolver/candidate.rb +94 -0
  115. data/lib/bundler/resolver/incompatibility.rb +15 -0
  116. data/lib/bundler/resolver/package.rb +72 -0
  117. data/lib/bundler/resolver/root.rb +25 -0
  118. data/lib/bundler/resolver/spec_group.rb +42 -70
  119. data/lib/bundler/resolver.rb +322 -326
  120. data/lib/bundler/ruby_dsl.rb +1 -1
  121. data/lib/bundler/ruby_version.rb +5 -5
  122. data/lib/bundler/rubygems_ext.rb +102 -12
  123. data/lib/bundler/rubygems_gem_installer.rb +32 -20
  124. data/lib/bundler/rubygems_integration.rb +12 -34
  125. data/lib/bundler/runtime.rb +1 -6
  126. data/lib/bundler/settings.rb +2 -8
  127. data/lib/bundler/shared_helpers.rb +7 -7
  128. data/lib/bundler/source/git/git_proxy.rb +193 -67
  129. data/lib/bundler/source/git.rb +21 -25
  130. data/lib/bundler/source/metadata.rb +1 -2
  131. data/lib/bundler/source/path/installer.rb +1 -22
  132. data/lib/bundler/source/path.rb +6 -6
  133. data/lib/bundler/source/rubygems.rb +75 -117
  134. data/lib/bundler/source.rb +3 -4
  135. data/lib/bundler/source_list.rb +12 -2
  136. data/lib/bundler/spec_set.rb +52 -34
  137. data/lib/bundler/stub_specification.rb +5 -3
  138. data/lib/bundler/templates/Executable +1 -1
  139. data/lib/bundler/templates/Executable.bundler +4 -9
  140. data/lib/bundler/templates/Executable.standalone +2 -0
  141. data/lib/bundler/templates/newgem/Cargo.toml.tt +7 -0
  142. data/lib/bundler/templates/newgem/Gemfile.tt +3 -0
  143. data/lib/bundler/templates/newgem/README.md.tt +6 -4
  144. data/lib/bundler/templates/newgem/Rakefile.tt +2 -1
  145. data/lib/bundler/templates/newgem/circleci/config.yml.tt +12 -0
  146. data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +15 -0
  147. data/lib/bundler/templates/newgem/ext/newgem/extconf-rust.rb.tt +6 -0
  148. data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +12 -0
  149. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +10 -0
  150. data/lib/bundler/templates/newgem/gitignore.tt +3 -0
  151. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +13 -4
  152. data/lib/bundler/templates/newgem/newgem.gemspec.tt +8 -2
  153. data/lib/bundler/ui/shell.rb +35 -12
  154. data/lib/bundler/ui/silent.rb +21 -5
  155. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +3 -3
  156. data/lib/bundler/vendor/connection_pool/lib/connection_pool/wrapper.rb +0 -1
  157. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +3 -1
  158. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1350 -408
  159. data/lib/bundler/vendor/net-http-persistent/README.rdoc +1 -1
  160. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1 -1
  161. data/lib/bundler/vendor/pub_grub/LICENSE.txt +21 -0
  162. data/lib/bundler/vendor/pub_grub/lib/pub_grub/assignment.rb +20 -0
  163. data/lib/bundler/vendor/pub_grub/lib/pub_grub/basic_package_source.rb +189 -0
  164. data/lib/bundler/vendor/pub_grub/lib/pub_grub/failure_writer.rb +182 -0
  165. data/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb +151 -0
  166. data/lib/bundler/vendor/pub_grub/lib/pub_grub/package.rb +43 -0
  167. data/lib/bundler/vendor/pub_grub/lib/pub_grub/partial_solution.rb +121 -0
  168. data/lib/bundler/vendor/pub_grub/lib/pub_grub/rubygems.rb +45 -0
  169. data/lib/bundler/vendor/pub_grub/lib/pub_grub/solve_failure.rb +19 -0
  170. data/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb +53 -0
  171. data/lib/bundler/vendor/pub_grub/lib/pub_grub/term.rb +105 -0
  172. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version.rb +3 -0
  173. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb +128 -0
  174. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb +409 -0
  175. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb +240 -0
  176. data/lib/bundler/vendor/pub_grub/lib/pub_grub/version_union.rb +178 -0
  177. data/lib/bundler/vendor/pub_grub/lib/pub_grub.rb +31 -0
  178. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +1 -1
  179. data/lib/bundler/vendor/uri/lib/uri/common.rb +64 -16
  180. data/lib/bundler/vendor/uri/lib/uri/file.rb +7 -1
  181. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +2 -1
  182. data/lib/bundler/vendor/uri/lib/uri/generic.rb +27 -7
  183. data/lib/bundler/vendor/uri/lib/uri/http.rb +40 -2
  184. data/lib/bundler/vendor/uri/lib/uri/https.rb +2 -1
  185. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +1 -1
  186. data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +2 -1
  187. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +2 -2
  188. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +13 -7
  189. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +10 -5
  190. data/lib/bundler/vendor/uri/lib/uri/version.rb +1 -1
  191. data/lib/bundler/vendor/uri/lib/uri/ws.rb +1 -2
  192. data/lib/bundler/vendor/uri/lib/uri/wss.rb +2 -1
  193. data/lib/bundler/vendor/uri/lib/uri.rb +3 -2
  194. data/lib/bundler/vendored_persistent.rb +1 -33
  195. data/lib/bundler/{vendored_tmpdir.rb → vendored_pub_grub.rb} +1 -1
  196. data/lib/bundler/version.rb +5 -1
  197. data/lib/bundler/worker.rb +5 -7
  198. data/lib/bundler.rb +35 -69
  199. metadata +45 -34
  200. data/lib/bundler/dep_proxy.rb +0 -55
  201. data/lib/bundler/templates/newgem/travis.yml.tt +0 -6
  202. data/lib/bundler/vendor/molinillo/LICENSE +0 -9
  203. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +0 -57
  204. data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +0 -88
  205. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +0 -36
  206. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +0 -66
  207. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +0 -62
  208. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +0 -63
  209. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +0 -61
  210. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +0 -126
  211. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +0 -46
  212. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +0 -36
  213. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +0 -164
  214. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +0 -255
  215. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +0 -149
  216. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +0 -6
  217. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +0 -112
  218. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +0 -67
  219. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +0 -839
  220. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +0 -46
  221. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +0 -58
  222. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +0 -11
  223. data/lib/bundler/vendor/tmpdir/lib/tmpdir.rb +0 -154
  224. data/lib/bundler/vendored_molinillo.rb +0 -4
  225. data/lib/bundler/version_ranges.rb +0 -122
  226. /data/lib/bundler/templates/newgem/ext/newgem/{extconf.rb.tt → extconf-c.rb.tt} +0 -0
@@ -9,7 +9,7 @@ module Bundler
9
9
  raise GemfileError, "Please define :engine" if options[:engine_version] && options[:engine].nil?
10
10
 
11
11
  if options[:engine] == "ruby" && options[:engine_version] &&
12
- ruby_version != Array(options[:engine_version])
12
+ ruby_version != Array(options[:engine_version])
13
13
  raise GemfileEvalError, "ruby_version must match the :engine_version for MRI"
14
14
  end
15
15
  @ruby_version = RubyVersion.new(ruby_version, options[:patchlevel], options[:engine], options[:engine_version])
@@ -32,12 +32,12 @@ module Bundler
32
32
  @engine = engine && engine.to_s || "ruby"
33
33
  @engine_versions = (engine_version && Array(engine_version)) || @versions
34
34
  @engine_gem_version = Gem::Requirement.create(@engine_versions.first).requirements.first.last
35
- @patchlevel = patchlevel
35
+ @patchlevel = patchlevel || (@gem_version.prerelease? ? "-1" : nil)
36
36
  end
37
37
 
38
38
  def to_s(versions = self.versions)
39
39
  output = String.new("ruby #{versions_string(versions)}")
40
- output << "p#{patchlevel}" if patchlevel
40
+ output << "p#{patchlevel}" if patchlevel && patchlevel != "-1"
41
41
  output << " (#{engine} #{versions_string(engine_versions)})" unless engine == "ruby"
42
42
 
43
43
  output
@@ -46,7 +46,7 @@ module Bundler
46
46
  # @private
47
47
  PATTERN = /
48
48
  ruby\s
49
- ([\d.]+) # ruby version
49
+ (\d+\.\d+\.\d+(?:\.\S+)?) # ruby version
50
50
  (?:p(-?\d+))? # optional patchlevel
51
51
  (?:\s\((\S+)\s(.+)\))? # optional engine info
52
52
  /xo.freeze
@@ -103,8 +103,8 @@ module Bundler
103
103
 
104
104
  def self.system
105
105
  ruby_engine = RUBY_ENGINE.dup
106
- ruby_version = RUBY_VERSION.dup
107
- ruby_engine_version = RUBY_ENGINE_VERSION.dup
106
+ ruby_version = Gem.ruby_version.to_s
107
+ ruby_engine_version = RUBY_ENGINE == "ruby" ? ruby_version : RUBY_ENGINE_VERSION.dup
108
108
  patchlevel = RUBY_PATCHLEVEL.to_s
109
109
 
110
110
  @ruby_version ||= RubyVersion.new(ruby_version, patchlevel, ruby_engine, ruby_engine_version)
@@ -15,10 +15,22 @@ require "rubygems/specification"
15
15
  # `Gem::Source` from the redefined `Gem::Specification#source`.
16
16
  require "rubygems/source"
17
17
 
18
+ require_relative "match_metadata"
19
+ require_relative "force_platform"
18
20
  require_relative "match_platform"
19
21
 
22
+ # Cherry-pick fixes to `Gem.ruby_version` to be useful for modern Bundler
23
+ # versions and ignore patchlevels
24
+ # (https://github.com/rubygems/rubygems/pull/5472,
25
+ # https://github.com/rubygems/rubygems/pull/5486). May be removed once RubyGems
26
+ # 3.3.12 support is dropped.
27
+ unless Gem.ruby_version.to_s == RUBY_VERSION || RUBY_PATCHLEVEL == -1
28
+ Gem.instance_variable_set(:@ruby_version, Gem::Version.new(RUBY_VERSION))
29
+ end
30
+
20
31
  module Gem
21
32
  class Specification
33
+ include ::Bundler::MatchMetadata
22
34
  include ::Bundler::MatchPlatform
23
35
 
24
36
  attr_accessor :remote, :location, :relative_loaded_from
@@ -34,7 +46,7 @@ module Gem
34
46
 
35
47
  def full_gem_path
36
48
  if source.respond_to?(:root)
37
- Pathname.new(loaded_from).dirname.expand_path(source.root).to_s.tap{|x| x.untaint if RUBY_VERSION < "2.7" }
49
+ Pathname.new(loaded_from).dirname.expand_path(source.root).to_s.tap {|x| x.untaint if RUBY_VERSION < "2.7" }
38
50
  else
39
51
  rg_full_gem_path
40
52
  end
@@ -142,10 +154,18 @@ module Gem
142
154
  end
143
155
 
144
156
  class Dependency
157
+ include ::Bundler::ForcePlatform
158
+
145
159
  attr_accessor :source, :groups
146
160
 
147
161
  alias_method :eql?, :==
148
162
 
163
+ def force_ruby_platform
164
+ return @force_ruby_platform if defined?(@force_ruby_platform) && !@force_ruby_platform.nil?
165
+
166
+ @force_ruby_platform = default_force_ruby_platform
167
+ end
168
+
149
169
  def encode_with(coder)
150
170
  to_yaml_properties.each do |ivar|
151
171
  coder[ivar.to_s.sub(/^@/, "")] = instance_variable_get(ivar)
@@ -216,11 +236,56 @@ module Gem
216
236
  require "rubygems/platform"
217
237
 
218
238
  class Platform
219
- JAVA = Gem::Platform.new("java") unless defined?(JAVA)
220
- MSWIN = Gem::Platform.new("mswin32") unless defined?(MSWIN)
221
- MSWIN64 = Gem::Platform.new("mswin64") unless defined?(MSWIN64)
222
- MINGW = Gem::Platform.new("x86-mingw32") unless defined?(MINGW)
223
- X64_MINGW = Gem::Platform.new("x64-mingw32") unless defined?(X64_MINGW)
239
+ JAVA = Gem::Platform.new("java")
240
+ MSWIN = Gem::Platform.new("mswin32")
241
+ MSWIN64 = Gem::Platform.new("mswin64")
242
+ MINGW = Gem::Platform.new("x86-mingw32")
243
+ X64_MINGW = [Gem::Platform.new("x64-mingw32"),
244
+ Gem::Platform.new("x64-mingw-ucrt")].freeze
245
+ WINDOWS = [MSWIN, MSWIN64, MINGW, X64_MINGW].flatten.freeze
246
+ X64_LINUX = Gem::Platform.new("x86_64-linux")
247
+ X64_LINUX_MUSL = Gem::Platform.new("x86_64-linux-musl")
248
+
249
+ if X64_LINUX === X64_LINUX_MUSL
250
+ remove_method :===
251
+
252
+ def ===(other)
253
+ return nil unless Gem::Platform === other
254
+
255
+ # universal-mingw32 matches x64-mingw-ucrt
256
+ return true if (@cpu == "universal" || other.cpu == "universal") &&
257
+ @os.start_with?("mingw") && other.os.start_with?("mingw")
258
+
259
+ # cpu
260
+ ([nil,"universal"].include?(@cpu) || [nil, "universal"].include?(other.cpu) || @cpu == other.cpu ||
261
+ (@cpu == "arm" && other.cpu.start_with?("arm"))) &&
262
+
263
+ # os
264
+ @os == other.os &&
265
+
266
+ # version
267
+ (
268
+ (@os != "linux" && (@version.nil? || other.version.nil?)) ||
269
+ (@os == "linux" && (normalized_linux_version_ext == other.normalized_linux_version_ext || ["musl#{@version}", "musleabi#{@version}", "musleabihf#{@version}"].include?(other.version))) ||
270
+ @version == other.version
271
+ )
272
+ end
273
+
274
+ # This is a copy of RubyGems 3.3.23 or higher `normalized_linux_method`.
275
+ # Once only 3.3.23 is supported, we can use the method in RubyGems.
276
+ def normalized_linux_version_ext
277
+ return nil unless @version
278
+
279
+ without_gnu_nor_abi_modifiers = @version.sub(/\Agnu/, "").sub(/eabi(hf)?\Z/, "")
280
+ return nil if without_gnu_nor_abi_modifiers.empty?
281
+
282
+ without_gnu_nor_abi_modifiers
283
+ end
284
+ end
285
+
286
+ if RUBY_ENGINE == "truffleruby" && !defined?(REUSE_AS_BINARY_ON_TRUFFLERUBY)
287
+ REUSE_AS_BINARY_ON_TRUFFLERUBY = %w[libv8 libv8-node sorbet-static].freeze
288
+ end
224
289
  end
225
290
 
226
291
  Platform.singleton_class.module_eval do
@@ -232,14 +297,43 @@ module Gem
232
297
  def match_gem?(platform, gem_name)
233
298
  match_platforms?(platform, Gem.platforms)
234
299
  end
300
+ end
301
+
302
+ match_platforms_defined = Gem::Platform.respond_to?(:match_platforms?, true)
303
+
304
+ if !match_platforms_defined || Gem::Platform.send(:match_platforms?, Gem::Platform::X64_LINUX_MUSL, [Gem::Platform::X64_LINUX])
235
305
 
236
306
  private
237
307
 
308
+ remove_method :match_platforms? if match_platforms_defined
309
+
238
310
  def match_platforms?(platform, platforms)
239
311
  platforms.any? do |local_platform|
240
312
  platform.nil? ||
241
313
  local_platform == platform ||
242
- (local_platform != Gem::Platform::RUBY && local_platform =~ platform)
314
+ (local_platform != Gem::Platform::RUBY && platform =~ local_platform)
315
+ end
316
+ end
317
+ end
318
+ end
319
+
320
+ # On universal Rubies, resolve the "universal" arch to the real CPU arch, without changing the extension directory.
321
+ class Specification
322
+ if /^universal\.(?<arch>.*?)-/ =~ (CROSS_COMPILING || RUBY_PLATFORM)
323
+ local_platform = Platform.local
324
+ if local_platform.cpu == "universal"
325
+ ORIGINAL_LOCAL_PLATFORM = local_platform.to_s.freeze
326
+
327
+ local_platform.cpu = if arch == "arm64e" # arm64e is only permitted for Apple system binaries
328
+ "arm64"
329
+ else
330
+ arch
331
+ end
332
+
333
+ def extensions_dir
334
+ Gem.default_ext_dir_for(base_dir) ||
335
+ File.join(base_dir, "extensions", ORIGINAL_LOCAL_PLATFORM,
336
+ Gem.extension_api_version)
243
337
  end
244
338
  end
245
339
  end
@@ -253,11 +347,7 @@ module Gem
253
347
  end
254
348
 
255
349
  def glob_files_in_dir(glob, base_path)
256
- if RUBY_VERSION >= "2.5"
257
- Dir.glob(glob, :base => base_path).map! {|f| File.expand_path(f, base_path) }
258
- else
259
- Dir.glob(File.join(base_path.to_s.gsub(/[\[\]]/, '\\\\\\&'), glob)).map! {|f| File.expand_path(f) }
260
- end
350
+ Dir.glob(glob, :base => base_path).map! {|f| File.expand_path(f, base_path) }
261
351
  end
262
352
  end
263
353
  end
@@ -25,7 +25,7 @@ module Bundler
25
25
 
26
26
  extract_files
27
27
 
28
- build_extensions
28
+ build_extensions if spec.extensions.any?
29
29
  write_build_info_file
30
30
  run_post_build_hooks
31
31
 
@@ -66,41 +66,53 @@ module Bundler
66
66
 
67
67
  def build_extensions
68
68
  extension_cache_path = options[:bundler_extension_cache_path]
69
- unless extension_cache_path && extension_dir = spec.extension_dir
70
- require "shellwords" unless Bundler.rubygems.provides?(">= 3.2.25")
69
+ extension_dir = spec.extension_dir
70
+ unless extension_cache_path && extension_dir
71
+ prepare_extension_build(extension_dir)
71
72
  return super
72
73
  end
73
74
 
74
- extension_dir = Pathname.new(extension_dir)
75
75
  build_complete = SharedHelpers.filesystem_access(extension_cache_path.join("gem.build_complete"), :read, &:file?)
76
76
  if build_complete && !options[:force]
77
- SharedHelpers.filesystem_access(extension_dir.parent, &:mkpath)
77
+ SharedHelpers.filesystem_access(File.dirname(extension_dir)) do |p|
78
+ FileUtils.mkpath p
79
+ end
78
80
  SharedHelpers.filesystem_access(extension_cache_path) do
79
- FileUtils.cp_r extension_cache_path, spec.extension_dir
81
+ FileUtils.cp_r extension_cache_path, extension_dir
80
82
  end
81
83
  else
82
- require "shellwords" # compensate missing require in rubygems before version 3.2.25
84
+ prepare_extension_build(extension_dir)
83
85
  super
84
- if extension_dir.directory? # not made for gems without extensions
85
- SharedHelpers.filesystem_access(extension_cache_path.parent, &:mkpath)
86
- SharedHelpers.filesystem_access(extension_cache_path) do
87
- FileUtils.cp_r extension_dir, extension_cache_path
88
- end
86
+ SharedHelpers.filesystem_access(extension_cache_path.parent, &:mkpath)
87
+ SharedHelpers.filesystem_access(extension_cache_path) do
88
+ FileUtils.cp_r extension_dir, extension_cache_path
89
89
  end
90
90
  end
91
91
  end
92
92
 
93
+ def spec
94
+ if Bundler.rubygems.provides?("< 3.3.12") # RubyGems implementation rescues and re-raises errors before 3.3.12 and we don't want that
95
+ @package.spec
96
+ else
97
+ super
98
+ end
99
+ end
100
+
93
101
  private
94
102
 
103
+ def prepare_extension_build(extension_dir)
104
+ SharedHelpers.filesystem_access(extension_dir, :create) do
105
+ FileUtils.mkdir_p extension_dir
106
+ end
107
+ require "shellwords" unless Bundler.rubygems.provides?(">= 3.2.25")
108
+ end
109
+
95
110
  def strict_rm_rf(dir)
96
- # FileUtils.rm_rf should probably rise in case of permission issues like
97
- # `rm -rf` does. However, it fails to delete the folder silently due to
98
- # https://github.com/ruby/fileutils/issues/57. It should probably be fixed
99
- # inside `fileutils` but for now I`m checking whether the folder was
100
- # removed after it completes, and raising otherwise.
101
- FileUtils.rm_rf dir
102
-
103
- raise PermissionError.new(dir, :delete) if File.directory?(dir)
111
+ Bundler.rm_rf dir
112
+ rescue StandardError => e
113
+ raise unless File.exist?(dir)
114
+
115
+ raise DirectoryRemovalError.new(e, "Could not delete previous installation of `#{dir}`")
104
116
  end
105
117
 
106
118
  def validate_bundler_checksum(checksum)
@@ -203,20 +203,9 @@ module Bundler
203
203
  EXT_LOCK
204
204
  end
205
205
 
206
- def spec_from_gem(path, policy = nil)
207
- require "rubygems/security"
208
- require "psych"
209
- gem_from_path(path, security_policies[policy]).spec
210
- rescue Exception, Gem::Exception, Gem::Security::Exception => e # rubocop:disable Lint/RescueException
211
- if e.is_a?(Gem::Security::Exception) ||
212
- e.message =~ /unknown trust policy|unsigned gem/i ||
213
- e.message =~ /couldn't verify (meta)?data signature/i
214
- raise SecurityError,
215
- "The gem #{File.basename(path, ".gem")} can't be installed because " \
216
- "the security policy didn't allow it, with the message: #{e.message}"
217
- else
218
- raise e
219
- end
206
+ def spec_from_gem(path)
207
+ require "rubygems/package"
208
+ Gem::Package.new(path).spec
220
209
  end
221
210
 
222
211
  def build_gem(gem_dir, spec)
@@ -238,10 +227,14 @@ module Bundler
238
227
 
239
228
  def reverse_rubygems_kernel_mixin
240
229
  # Disable rubygems' gem activation system
241
- kernel = (class << ::Kernel; self; end)
242
- [kernel, ::Kernel].each do |k|
243
- if k.private_method_defined?(:gem_original_require)
244
- redefine_method(k, :require, k.instance_method(:gem_original_require))
230
+ if Gem.respond_to?(:discover_gems_on_require=)
231
+ Gem.discover_gems_on_require = false
232
+ else
233
+ kernel = (class << ::Kernel; self; end)
234
+ [kernel, ::Kernel].each do |k|
235
+ if k.private_method_defined?(:gem_original_require)
236
+ redefine_method(k, :require, k.instance_method(:gem_original_require))
237
+ end
245
238
  end
246
239
  end
247
240
  end
@@ -283,11 +276,7 @@ module Bundler
283
276
 
284
277
  e = Gem::LoadError.new(message)
285
278
  e.name = dep.name
286
- if e.respond_to?(:requirement=)
287
- e.requirement = dep.requirement
288
- elsif e.respond_to?(:version_requirement=)
289
- e.version_requirement = dep.requirement
290
- end
279
+ e.requirement = dep.requirement
291
280
  raise e
292
281
  end
293
282
 
@@ -514,22 +503,11 @@ module Bundler
514
503
  Gem::RemoteFetcher.new(proxy)
515
504
  end
516
505
 
517
- def gem_from_path(path, policy = nil)
518
- require "rubygems/package"
519
- p = Gem::Package.new(path)
520
- p.security_policy = policy if policy
521
- p
522
- end
523
-
524
506
  def build(spec, skip_validation = false)
525
507
  require "rubygems/package"
526
508
  Gem::Package.build(spec, skip_validation)
527
509
  end
528
510
 
529
- def repository_subdirectories
530
- Gem::REPOSITORY_SUBDIRECTORIES
531
- end
532
-
533
511
  def path_separator
534
512
  Gem.path_separator
535
513
  end
@@ -125,7 +125,6 @@ module Bundler
125
125
  specs_to_cache.each do |spec|
126
126
  next if spec.name == "bundler"
127
127
  next if spec.source.is_a?(Source::Gemspec)
128
- spec.source.send(:fetch_gem, spec) if Bundler.settings[:cache_all_platforms] && spec.source.respond_to?(:fetch_gem, true)
129
128
  spec.source.cache(spec, custom_path) if spec.source.respond_to?(:cache)
130
129
  end
131
130
 
@@ -301,11 +300,7 @@ module Bundler
301
300
  e = Gem::LoadError.new "You have already activated #{activated_spec.name} #{activated_spec.version}, " \
302
301
  "but your Gemfile requires #{spec.name} #{spec.version}. #{suggestion}"
303
302
  e.name = spec.name
304
- if e.respond_to?(:requirement=)
305
- e.requirement = Gem::Requirement.new(spec.version.to_s)
306
- else
307
- e.version_requirement = Gem::Requirement.new(spec.version.to_s)
308
- end
303
+ e.requirement = Gem::Requirement.new(spec.version.to_s)
309
304
  raise e
310
305
  end
311
306
  end
@@ -45,7 +45,6 @@ module Bundler
45
45
  silence_root_warning
46
46
  suppress_install_using_messages
47
47
  update_requires_all_flag
48
- use_gem_version_promoter_for_major_updates
49
48
  ].freeze
50
49
 
51
50
  NUMBER_KEYS = %w[
@@ -57,6 +56,7 @@ module Bundler
57
56
  ].freeze
58
57
 
59
58
  ARRAY_KEYS = %w[
59
+ only
60
60
  with
61
61
  without
62
62
  ].freeze
@@ -277,12 +277,6 @@ module Bundler
277
277
  end
278
278
  end
279
279
 
280
- def allow_sudo?
281
- key = key_for(:path)
282
- path_configured = @temporary.key?(key) || @local_config.key?(key)
283
- !path_configured
284
- end
285
-
286
280
  def ignore_config?
287
281
  ENV["BUNDLE_IGNORE_CONFIG"]
288
282
  end
@@ -487,7 +481,7 @@ module Bundler
487
481
  /ix.freeze
488
482
 
489
483
  def self.key_for(key)
490
- key = normalize_uri(key).to_s if key.is_a?(String) && /https?:/ =~ key
484
+ key = normalize_uri(key).to_s if key.is_a?(String) && key.start_with?("http", "mirror.http")
491
485
  key = key.to_s.gsub(".", "__").gsub("-", "___").upcase
492
486
  "BUNDLE_#{key}"
493
487
  end
@@ -13,13 +13,13 @@ module Bundler
13
13
  def root
14
14
  gemfile = find_gemfile
15
15
  raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
16
- Pathname.new(gemfile).tap{|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path.parent
16
+ Pathname.new(gemfile).tap {|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path.parent
17
17
  end
18
18
 
19
19
  def default_gemfile
20
20
  gemfile = find_gemfile
21
21
  raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
22
- Pathname.new(gemfile).tap{|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path
22
+ Pathname.new(gemfile).tap {|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path
23
23
  end
24
24
 
25
25
  def default_lockfile
@@ -28,7 +28,7 @@ module Bundler
28
28
  case gemfile.basename.to_s
29
29
  when "gems.rb" then Pathname.new(gemfile.sub(/.rb$/, ".locked"))
30
30
  else Pathname.new("#{gemfile}.lock")
31
- end.tap{|x| x.untaint if RUBY_VERSION < "2.7" }
31
+ end.tap {|x| x.untaint if RUBY_VERSION < "2.7" }
32
32
  end
33
33
 
34
34
  def default_bundle_dir
@@ -100,7 +100,7 @@ module Bundler
100
100
  #
101
101
  # @see {Bundler::PermissionError}
102
102
  def filesystem_access(path, action = :write, &block)
103
- yield(path.dup.tap{|x| x.untaint if RUBY_VERSION < "2.7" })
103
+ yield(path.dup.tap {|x| x.untaint if RUBY_VERSION < "2.7" })
104
104
  rescue Errno::EACCES
105
105
  raise PermissionError.new(path, action)
106
106
  rescue Errno::EAGAIN
@@ -163,7 +163,7 @@ module Bundler
163
163
  "\nEither installing with `--full-index` or running `bundle update #{spec.name}` should fix the problem."
164
164
  end
165
165
 
166
- def pretty_dependency(dep, print_source = false)
166
+ def pretty_dependency(dep)
167
167
  msg = String.new(dep.name)
168
168
  msg << " (#{dep.requirement})" unless dep.requirement == Gem::Requirement.default
169
169
 
@@ -172,7 +172,6 @@ module Bundler
172
172
  msg << " " << platform_string if !platform_string.empty? && platform_string != Gem::Platform::RUBY
173
173
  end
174
174
 
175
- msg << " from the `#{dep.source}` source" if print_source && dep.source
176
175
  msg
177
176
  end
178
177
 
@@ -236,7 +235,7 @@ module Bundler
236
235
 
237
236
  def search_up(*names)
238
237
  previous = nil
239
- current = File.expand_path(SharedHelpers.pwd).tap{|x| x.untaint if RUBY_VERSION < "2.7" }
238
+ current = File.expand_path(SharedHelpers.pwd).tap {|x| x.untaint if RUBY_VERSION < "2.7" }
240
239
 
241
240
  until !File.directory?(current) || current == previous
242
241
  if ENV["BUNDLER_SPEC_RUN"]
@@ -285,6 +284,7 @@ module Bundler
285
284
  Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file
286
285
  Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", find_gemfile.to_s
287
286
  Bundler::SharedHelpers.set_env "BUNDLER_VERSION", Bundler::VERSION
287
+ Bundler::SharedHelpers.set_env "BUNDLER_SETUP", File.expand_path("setup", __dir__) unless RUBY_VERSION < "2.7"
288
288
  end
289
289
 
290
290
  def set_path