rubygems-update 3.6.8 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +874 -787
  3. data/CONTRIBUTING.md +9 -0
  4. data/Manifest.txt +6 -22
  5. data/README.md +1 -1
  6. data/SECURITY.md +7 -0
  7. data/bundler/CHANGELOG.md +1103 -1030
  8. data/bundler/README.md +7 -7
  9. data/bundler/bundler.gemspec +2 -2
  10. data/bundler/lib/bundler/build_metadata.rb +10 -11
  11. data/bundler/lib/bundler/cli/common.rb +1 -1
  12. data/bundler/lib/bundler/cli/config.rb +2 -2
  13. data/bundler/lib/bundler/cli/doctor/diagnose.rb +167 -0
  14. data/bundler/lib/bundler/cli/doctor/ssl.rb +249 -0
  15. data/bundler/lib/bundler/cli/doctor.rb +27 -155
  16. data/bundler/lib/bundler/cli/gem.rb +62 -30
  17. data/bundler/lib/bundler/cli/install.rb +4 -4
  18. data/bundler/lib/bundler/cli/issue.rb +2 -2
  19. data/bundler/lib/bundler/cli/outdated.rb +1 -1
  20. data/bundler/lib/bundler/cli/update.rb +2 -2
  21. data/bundler/lib/bundler/cli.rb +12 -25
  22. data/bundler/lib/bundler/compact_index_client.rb +1 -5
  23. data/bundler/lib/bundler/current_ruby.rb +27 -3
  24. data/bundler/lib/bundler/definition.rb +55 -58
  25. data/bundler/lib/bundler/dependency.rb +1 -1
  26. data/bundler/lib/bundler/dsl.rb +33 -23
  27. data/bundler/lib/bundler/feature_flag.rb +15 -12
  28. data/bundler/lib/bundler/fetcher/dependency.rb +2 -1
  29. data/bundler/lib/bundler/fetcher/downloader.rb +33 -7
  30. data/bundler/lib/bundler/fetcher.rb +49 -19
  31. data/bundler/lib/bundler/friendly_errors.rb +2 -1
  32. data/bundler/lib/bundler/index.rb +7 -2
  33. data/bundler/lib/bundler/installer.rb +5 -4
  34. data/bundler/lib/bundler/lazy_specification.rb +29 -18
  35. data/bundler/lib/bundler/lockfile_parser.rb +21 -5
  36. data/bundler/lib/bundler/man/bundle-add.1 +1 -1
  37. data/bundler/lib/bundler/man/bundle-binstubs.1 +1 -1
  38. data/bundler/lib/bundler/man/bundle-cache.1 +1 -1
  39. data/bundler/lib/bundler/man/bundle-check.1 +1 -1
  40. data/bundler/lib/bundler/man/bundle-clean.1 +1 -1
  41. data/bundler/lib/bundler/man/bundle-config.1 +172 -126
  42. data/bundler/lib/bundler/man/bundle-config.1.ronn +91 -91
  43. data/bundler/lib/bundler/man/bundle-console.1 +1 -1
  44. data/bundler/lib/bundler/man/bundle-doctor.1 +43 -4
  45. data/bundler/lib/bundler/man/bundle-doctor.1.ronn +48 -4
  46. data/bundler/lib/bundler/man/bundle-env.1 +1 -1
  47. data/bundler/lib/bundler/man/bundle-exec.1 +1 -1
  48. data/bundler/lib/bundler/man/bundle-fund.1 +1 -1
  49. data/bundler/lib/bundler/man/bundle-gem.1 +67 -44
  50. data/bundler/lib/bundler/man/bundle-gem.1.ronn +8 -4
  51. data/bundler/lib/bundler/man/bundle-help.1 +1 -1
  52. data/bundler/lib/bundler/man/bundle-info.1 +1 -1
  53. data/bundler/lib/bundler/man/bundle-init.1 +1 -1
  54. data/bundler/lib/bundler/man/bundle-inject.1 +2 -2
  55. data/bundler/lib/bundler/man/bundle-inject.1.ronn +1 -1
  56. data/bundler/lib/bundler/man/bundle-install.1 +1 -1
  57. data/bundler/lib/bundler/man/bundle-issue.1 +1 -1
  58. data/bundler/lib/bundler/man/bundle-licenses.1 +1 -1
  59. data/bundler/lib/bundler/man/bundle-list.1 +1 -1
  60. data/bundler/lib/bundler/man/bundle-lock.1 +1 -1
  61. data/bundler/lib/bundler/man/bundle-open.1 +1 -1
  62. data/bundler/lib/bundler/man/bundle-outdated.1 +1 -1
  63. data/bundler/lib/bundler/man/bundle-platform.1 +1 -1
  64. data/bundler/lib/bundler/man/bundle-plugin.1 +1 -1
  65. data/bundler/lib/bundler/man/bundle-pristine.1 +1 -1
  66. data/bundler/lib/bundler/man/bundle-remove.1 +1 -1
  67. data/bundler/lib/bundler/man/bundle-show.1 +1 -1
  68. data/bundler/lib/bundler/man/bundle-update.1 +1 -1
  69. data/bundler/lib/bundler/man/bundle-version.1 +1 -1
  70. data/bundler/lib/bundler/man/bundle-viz.1 +1 -1
  71. data/bundler/lib/bundler/man/bundle.1 +1 -1
  72. data/bundler/lib/bundler/man/gemfile.5 +1 -1
  73. data/bundler/lib/bundler/match_platform.rb +31 -12
  74. data/bundler/lib/bundler/materialization.rb +2 -2
  75. data/bundler/lib/bundler/resolver/package.rb +1 -1
  76. data/bundler/lib/bundler/resolver.rb +11 -9
  77. data/bundler/lib/bundler/rubygems_ext.rb +116 -120
  78. data/bundler/lib/bundler/rubygems_integration.rb +11 -6
  79. data/bundler/lib/bundler/runtime.rb +1 -1
  80. data/bundler/lib/bundler/self_manager.rb +32 -42
  81. data/bundler/lib/bundler/settings/validator.rb +0 -23
  82. data/bundler/lib/bundler/settings.rb +4 -6
  83. data/bundler/lib/bundler/shared_helpers.rb +6 -4
  84. data/bundler/lib/bundler/source/git/git_proxy.rb +3 -3
  85. data/bundler/lib/bundler/source/path.rb +7 -0
  86. data/bundler/lib/bundler/source_list.rb +1 -5
  87. data/bundler/lib/bundler/source_map.rb +1 -1
  88. data/bundler/lib/bundler/spec_set.rb +28 -6
  89. data/bundler/lib/bundler/templates/Executable +0 -11
  90. data/bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt +2 -0
  91. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +6 -5
  92. data/bundler/lib/bundler/ui/shell.rb +2 -2
  93. data/bundler/lib/bundler/vendor/net-http-persistent/README.rdoc +1 -1
  94. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +2 -1
  95. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +81 -42
  96. data/bundler/lib/bundler/version.rb +10 -2
  97. data/bundler/lib/bundler/worker.rb +1 -1
  98. data/bundler/lib/bundler.rb +14 -12
  99. data/doc/bundler/UPGRADING.md +137 -127
  100. data/doc/rubygems/CONTRIBUTING.md +1 -1
  101. data/lib/rubygems/basic_specification.rb +7 -0
  102. data/lib/rubygems/commands/pristine_command.rb +9 -12
  103. data/lib/rubygems/commands/push_command.rb +2 -1
  104. data/lib/rubygems/commands/setup_command.rb +2 -2
  105. data/lib/rubygems/core_ext/kernel_require.rb +5 -2
  106. data/lib/rubygems/ext/builder.rb +15 -4
  107. data/lib/rubygems/ext/cargo_builder.rb +7 -5
  108. data/lib/rubygems/ext/rake_builder.rb +1 -3
  109. data/lib/rubygems/gemcutter_utilities/webauthn_listener.rb +10 -3
  110. data/lib/rubygems/gemcutter_utilities.rb +5 -2
  111. data/lib/rubygems/installer.rb +45 -50
  112. data/lib/rubygems/package/tar_writer.rb +5 -4
  113. data/lib/rubygems/platform.rb +142 -39
  114. data/lib/rubygems/remote_fetcher.rb +3 -3
  115. data/lib/rubygems/request_set.rb +3 -6
  116. data/lib/rubygems/resolver/best_set.rb +1 -1
  117. data/lib/rubygems/resolver/source_set.rb +1 -1
  118. data/lib/rubygems/resolver.rb +1 -1
  119. data/lib/rubygems/s3_uri_signer.rb +5 -3
  120. data/lib/rubygems/source.rb +28 -22
  121. data/lib/rubygems/specification.rb +2 -2
  122. data/lib/rubygems/uri_formatter.rb +2 -1
  123. data/lib/rubygems/util/licenses.rb +21 -0
  124. data/lib/rubygems/vendor/net-http/lib/net/http.rb +14 -19
  125. data/lib/rubygems/vendor/resolv/lib/resolv.rb +50 -22
  126. data/lib/rubygems.rb +65 -7
  127. data/rubygems-update.gemspec +2 -2
  128. data/setup.rb +1 -1
  129. metadata +9 -25
  130. data/bundler/lib/bundler/gem_helpers.rb +0 -144
  131. data/bundler/lib/bundler/templates/Executable.bundler +0 -109
  132. data/bundler/lib/bundler/vendor/fileutils/.document +0 -1
  133. data/bundler/lib/bundler/vendor/net-http-persistent/.document +0 -1
  134. data/bundler/lib/bundler/vendor/pub_grub/.document +0 -1
  135. data/bundler/lib/bundler/vendor/securerandom/.document +0 -1
  136. data/bundler/lib/bundler/vendor/thor/.document +0 -1
  137. data/bundler/lib/bundler/vendor/tsort/.document +0 -1
  138. data/bundler/lib/bundler/vendor/uri/.document +0 -1
  139. data/lib/rubygems/shellwords.rb +0 -3
  140. data/lib/rubygems/ssl_certs/rubygems.org/GlobalSignRootCA.pem +0 -21
  141. data/lib/rubygems/vendor/molinillo/.document +0 -1
  142. data/lib/rubygems/vendor/net-http/.document +0 -1
  143. data/lib/rubygems/vendor/net-protocol/.document +0 -1
  144. data/lib/rubygems/vendor/optparse/.document +0 -1
  145. data/lib/rubygems/vendor/resolv/.document +0 -1
  146. data/lib/rubygems/vendor/securerandom/.document +0 -1
  147. data/lib/rubygems/vendor/timeout/.document +0 -1
  148. data/lib/rubygems/vendor/tsort/.document +0 -1
  149. data/lib/rubygems/vendor/uri/.document +0 -1
  150. /data/lib/rubygems/ssl_certs/rubygems.org/{GlobalSignRootCA_R3.pem → GlobalSign.pem} +0 -0
  151. /data/{bundler/lib/bundler/vendor/connection_pool → lib/rubygems/vendor}/.document +0 -0
@@ -1,6 +1,6 @@
1
1
  .\" generated with Ronn-NG/v0.10.1
2
2
  .\" http://github.com/apjanke/ronn-ng/tree/0.10.1
3
- .TH "BUNDLE\-INIT" "1" "March 2025" ""
3
+ .TH "BUNDLE\-INIT" "1" "July 2025" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-init\fR \- Generates a Gemfile into the current working directory
6
6
  .SH "SYNOPSIS"
@@ -1,6 +1,6 @@
1
1
  .\" generated with Ronn-NG/v0.10.1
2
2
  .\" http://github.com/apjanke/ronn-ng/tree/0.10.1
3
- .TH "BUNDLE\-INJECT" "1" "March 2025" ""
3
+ .TH "BUNDLE\-INJECT" "1" "July 2025" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-inject\fR \- Add named gem(s) with version requirements to Gemfile
6
6
  .SH "SYNOPSIS"
@@ -20,7 +20,7 @@ bundle inject 'rack' '> 0'
20
20
  .P
21
21
  This will inject the 'rack' gem with a version greater than 0 in your [\fBGemfile(5)\fR][Gemfile(5)] and Gemfile\.lock\.
22
22
  .P
23
- The \fBbundle inject\fR command was deprecated in Bundler 2\.1 and will be removed in Bundler 3\.0\.
23
+ The \fBbundle inject\fR command was deprecated in Bundler 2\.1 and will be removed in Bundler 4\.0\.
24
24
  .SH "OPTIONS"
25
25
  .TP
26
26
  \fB\-\-source=SOURCE\fR
@@ -21,7 +21,7 @@ Example:
21
21
  This will inject the 'rack' gem with a version greater than 0 in your
22
22
  [`Gemfile(5)`][Gemfile(5)] and Gemfile.lock.
23
23
 
24
- The `bundle inject` command was deprecated in Bundler 2.1 and will be removed in Bundler 3.0.
24
+ The `bundle inject` command was deprecated in Bundler 2.1 and will be removed in Bundler 4.0.
25
25
 
26
26
  ## OPTIONS
27
27
 
@@ -1,6 +1,6 @@
1
1
  .\" generated with Ronn-NG/v0.10.1
2
2
  .\" http://github.com/apjanke/ronn-ng/tree/0.10.1
3
- .TH "BUNDLE\-INSTALL" "1" "March 2025" ""
3
+ .TH "BUNDLE\-INSTALL" "1" "July 2025" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-install\fR \- Install the dependencies specified in your Gemfile
6
6
  .SH "SYNOPSIS"
@@ -1,6 +1,6 @@
1
1
  .\" generated with Ronn-NG/v0.10.1
2
2
  .\" http://github.com/apjanke/ronn-ng/tree/0.10.1
3
- .TH "BUNDLE\-ISSUE" "1" "March 2025" ""
3
+ .TH "BUNDLE\-ISSUE" "1" "July 2025" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-issue\fR \- Get help reporting Bundler issues
6
6
  .SH "SYNOPSIS"
@@ -1,6 +1,6 @@
1
1
  .\" generated with Ronn-NG/v0.10.1
2
2
  .\" http://github.com/apjanke/ronn-ng/tree/0.10.1
3
- .TH "BUNDLE\-LICENSES" "1" "March 2025" ""
3
+ .TH "BUNDLE\-LICENSES" "1" "July 2025" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-licenses\fR \- Print the license of all gems in the bundle
6
6
  .SH "SYNOPSIS"
@@ -1,6 +1,6 @@
1
1
  .\" generated with Ronn-NG/v0.10.1
2
2
  .\" http://github.com/apjanke/ronn-ng/tree/0.10.1
3
- .TH "BUNDLE\-LIST" "1" "March 2025" ""
3
+ .TH "BUNDLE\-LIST" "1" "July 2025" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-list\fR \- List all the gems in the bundle
6
6
  .SH "SYNOPSIS"
@@ -1,6 +1,6 @@
1
1
  .\" generated with Ronn-NG/v0.10.1
2
2
  .\" http://github.com/apjanke/ronn-ng/tree/0.10.1
3
- .TH "BUNDLE\-LOCK" "1" "March 2025" ""
3
+ .TH "BUNDLE\-LOCK" "1" "July 2025" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-lock\fR \- Creates / Updates a lockfile without installing
6
6
  .SH "SYNOPSIS"
@@ -1,6 +1,6 @@
1
1
  .\" generated with Ronn-NG/v0.10.1
2
2
  .\" http://github.com/apjanke/ronn-ng/tree/0.10.1
3
- .TH "BUNDLE\-OPEN" "1" "March 2025" ""
3
+ .TH "BUNDLE\-OPEN" "1" "July 2025" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-open\fR \- Opens the source directory for a gem in your bundle
6
6
  .SH "SYNOPSIS"
@@ -1,6 +1,6 @@
1
1
  .\" generated with Ronn-NG/v0.10.1
2
2
  .\" http://github.com/apjanke/ronn-ng/tree/0.10.1
3
- .TH "BUNDLE\-OUTDATED" "1" "March 2025" ""
3
+ .TH "BUNDLE\-OUTDATED" "1" "July 2025" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-outdated\fR \- List installed gems with newer versions available
6
6
  .SH "SYNOPSIS"
@@ -1,6 +1,6 @@
1
1
  .\" generated with Ronn-NG/v0.10.1
2
2
  .\" http://github.com/apjanke/ronn-ng/tree/0.10.1
3
- .TH "BUNDLE\-PLATFORM" "1" "March 2025" ""
3
+ .TH "BUNDLE\-PLATFORM" "1" "July 2025" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-platform\fR \- Displays platform compatibility information
6
6
  .SH "SYNOPSIS"
@@ -1,6 +1,6 @@
1
1
  .\" generated with Ronn-NG/v0.10.1
2
2
  .\" http://github.com/apjanke/ronn-ng/tree/0.10.1
3
- .TH "BUNDLE\-PLUGIN" "1" "March 2025" ""
3
+ .TH "BUNDLE\-PLUGIN" "1" "July 2025" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-plugin\fR \- Manage Bundler plugins
6
6
  .SH "SYNOPSIS"
@@ -1,6 +1,6 @@
1
1
  .\" generated with Ronn-NG/v0.10.1
2
2
  .\" http://github.com/apjanke/ronn-ng/tree/0.10.1
3
- .TH "BUNDLE\-PRISTINE" "1" "March 2025" ""
3
+ .TH "BUNDLE\-PRISTINE" "1" "July 2025" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-pristine\fR \- Restores installed gems to their pristine condition
6
6
  .SH "SYNOPSIS"
@@ -1,6 +1,6 @@
1
1
  .\" generated with Ronn-NG/v0.10.1
2
2
  .\" http://github.com/apjanke/ronn-ng/tree/0.10.1
3
- .TH "BUNDLE\-REMOVE" "1" "March 2025" ""
3
+ .TH "BUNDLE\-REMOVE" "1" "July 2025" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-remove\fR \- Removes gems from the Gemfile
6
6
  .SH "SYNOPSIS"
@@ -1,6 +1,6 @@
1
1
  .\" generated with Ronn-NG/v0.10.1
2
2
  .\" http://github.com/apjanke/ronn-ng/tree/0.10.1
3
- .TH "BUNDLE\-SHOW" "1" "March 2025" ""
3
+ .TH "BUNDLE\-SHOW" "1" "July 2025" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-show\fR \- Shows all the gems in your bundle, or the path to a gem
6
6
  .SH "SYNOPSIS"
@@ -1,6 +1,6 @@
1
1
  .\" generated with Ronn-NG/v0.10.1
2
2
  .\" http://github.com/apjanke/ronn-ng/tree/0.10.1
3
- .TH "BUNDLE\-UPDATE" "1" "March 2025" ""
3
+ .TH "BUNDLE\-UPDATE" "1" "July 2025" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-update\fR \- Update your gems to the latest available versions
6
6
  .SH "SYNOPSIS"
@@ -1,6 +1,6 @@
1
1
  .\" generated with Ronn-NG/v0.10.1
2
2
  .\" http://github.com/apjanke/ronn-ng/tree/0.10.1
3
- .TH "BUNDLE\-VERSION" "1" "March 2025" ""
3
+ .TH "BUNDLE\-VERSION" "1" "July 2025" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-version\fR \- Prints Bundler version information
6
6
  .SH "SYNOPSIS"
@@ -1,6 +1,6 @@
1
1
  .\" generated with Ronn-NG/v0.10.1
2
2
  .\" http://github.com/apjanke/ronn-ng/tree/0.10.1
3
- .TH "BUNDLE\-VIZ" "1" "March 2025" ""
3
+ .TH "BUNDLE\-VIZ" "1" "July 2025" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-viz\fR \- Generates a visual dependency graph for your Gemfile
6
6
  .SH "SYNOPSIS"
@@ -1,6 +1,6 @@
1
1
  .\" generated with Ronn-NG/v0.10.1
2
2
  .\" http://github.com/apjanke/ronn-ng/tree/0.10.1
3
- .TH "BUNDLE" "1" "March 2025" ""
3
+ .TH "BUNDLE" "1" "July 2025" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\fR \- Ruby Dependency Management
6
6
  .SH "SYNOPSIS"
@@ -1,6 +1,6 @@
1
1
  .\" generated with Ronn-NG/v0.10.1
2
2
  .\" http://github.com/apjanke/ronn-ng/tree/0.10.1
3
- .TH "GEMFILE" "5" "March 2025" ""
3
+ .TH "GEMFILE" "5" "July 2025" ""
4
4
  .SH "NAME"
5
5
  \fBGemfile\fR \- A format for describing gem dependencies for Ruby programs
6
6
  .SH "SYNOPSIS"
@@ -1,23 +1,42 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "gem_helpers"
4
-
5
3
  module Bundler
6
4
  module MatchPlatform
7
- include GemHelpers
5
+ def installable_on_platform?(target_platform) # :nodoc:
6
+ return true if [Gem::Platform::RUBY, nil, target_platform].include?(platform)
7
+ return true if Gem::Platform.new(platform) === target_platform
8
8
 
9
- def match_platform(p)
10
- MatchPlatform.platforms_match?(platform, p)
9
+ false
11
10
  end
12
11
 
13
- def self.platforms_match?(gemspec_platform, local_platform)
14
- return true if gemspec_platform.nil?
15
- return true if gemspec_platform == Gem::Platform::RUBY
16
- return true if local_platform == gemspec_platform
17
- gemspec_platform = Gem::Platform.new(gemspec_platform)
18
- return true if gemspec_platform === local_platform
12
+ def self.select_best_platform_match(specs, platform, force_ruby: false, prefer_locked: false)
13
+ matching = select_all_platform_match(specs, platform, force_ruby: force_ruby, prefer_locked: prefer_locked)
19
14
 
20
- false
15
+ Gem::Platform.sort_and_filter_best_platform_match(matching, platform)
16
+ end
17
+
18
+ def self.select_best_local_platform_match(specs, force_ruby: false)
19
+ local = Bundler.local_platform
20
+ matching = select_all_platform_match(specs, local, force_ruby: force_ruby).filter_map(&:materialized_for_installation)
21
+
22
+ Gem::Platform.sort_best_platform_match(matching, local)
23
+ end
24
+
25
+ def self.select_all_platform_match(specs, platform, force_ruby: false, prefer_locked: false)
26
+ matching = specs.select {|spec| spec.installable_on_platform?(force_ruby ? Gem::Platform::RUBY : platform) }
27
+
28
+ specs.each(&:force_ruby_platform!) if force_ruby
29
+
30
+ if prefer_locked
31
+ locked_originally = matching.select {|spec| spec.is_a?(::Bundler::LazySpecification) }
32
+ return locked_originally if locked_originally.any?
33
+ end
34
+
35
+ matching
36
+ end
37
+
38
+ def self.generic_local_platform_is_ruby?
39
+ Bundler.generic_local_platform == Gem::Platform::RUBY
21
40
  end
22
41
  end
23
42
  end
@@ -22,9 +22,9 @@ module Bundler
22
22
  @specs ||= if @candidates.nil?
23
23
  []
24
24
  elsif platform
25
- GemHelpers.select_best_platform_match(@candidates, platform, force_ruby: dep.force_ruby_platform)
25
+ MatchPlatform.select_best_platform_match(@candidates, platform, force_ruby: dep.force_ruby_platform)
26
26
  else
27
- GemHelpers.select_best_local_platform_match(@candidates, force_ruby: dep.force_ruby_platform || dep.default_force_ruby_platform)
27
+ MatchPlatform.select_best_local_platform_match(@candidates, force_ruby: dep.force_ruby_platform || dep.default_force_ruby_platform)
28
28
  end
29
29
  end
30
30
 
@@ -30,7 +30,7 @@ module Bundler
30
30
  def platform_specs(specs)
31
31
  platforms.map do |platform|
32
32
  prefer_locked = @new_platforms.include?(platform) ? false : !unlock?
33
- GemHelpers.select_best_platform_match(specs, platform, prefer_locked: prefer_locked)
33
+ MatchPlatform.select_best_platform_match(specs, platform, prefer_locked: prefer_locked)
34
34
  end
35
35
  end
36
36
 
@@ -14,8 +14,6 @@ module Bundler
14
14
  require_relative "resolver/root"
15
15
  require_relative "resolver/strategy"
16
16
 
17
- include GemHelpers
18
-
19
17
  def initialize(base, gem_version_promoter, most_specific_locked_platform = nil)
20
18
  @source_requirements = base.source_requirements
21
19
  @base = base
@@ -273,7 +271,7 @@ module Bundler
273
271
  next groups if platform_specs.all?(&:empty?)
274
272
  end
275
273
 
276
- ruby_specs = select_best_platform_match(specs, Gem::Platform::RUBY)
274
+ ruby_specs = MatchPlatform.select_best_platform_match(specs, Gem::Platform::RUBY)
277
275
  ruby_group = Resolver::SpecGroup.new(ruby_specs)
278
276
 
279
277
  unless ruby_group.empty?
@@ -312,6 +310,16 @@ module Bundler
312
310
  "Gemfile"
313
311
  end
314
312
 
313
+ def raise_incomplete!(incomplete_specs)
314
+ raise_not_found!(@base.get_package(incomplete_specs.first.name))
315
+ end
316
+
317
+ def sort_versions_by_preferred(package, versions)
318
+ @gem_version_promoter.sort_versions(package, versions)
319
+ end
320
+
321
+ private
322
+
315
323
  def raise_not_found!(package)
316
324
  name = package.name
317
325
  source = source_for(name)
@@ -348,12 +356,6 @@ module Bundler
348
356
  raise GemNotFound, message
349
357
  end
350
358
 
351
- def sort_versions_by_preferred(package, versions)
352
- @gem_version_promoter.sort_versions(package, versions)
353
- end
354
-
355
- private
356
-
357
359
  def filtered_versions_for(package)
358
360
  @gem_version_promoter.filter_versions(package, @all_versions[package])
359
361
  end
@@ -13,15 +13,6 @@ require "rubygems" unless defined?(Gem)
13
13
  # `Gem::Source` from the redefined `Gem::Specification#source`.
14
14
  require "rubygems/source"
15
15
 
16
- # Cherry-pick fixes to `Gem.ruby_version` to be useful for modern Bundler
17
- # versions and ignore patchlevels
18
- # (https://github.com/rubygems/rubygems/pull/5472,
19
- # https://github.com/rubygems/rubygems/pull/5486). May be removed once RubyGems
20
- # 3.3.12 support is dropped.
21
- unless Gem.ruby_version.to_s == RUBY_VERSION || RUBY_PATCHLEVEL == -1
22
- Gem.instance_variable_set(:@ruby_version, Gem::Version.new(RUBY_VERSION))
23
- end
24
-
25
16
  module Gem
26
17
  # Can be removed once RubyGems 3.5.11 support is dropped
27
18
  unless Gem.respond_to?(:freebsd_platform?)
@@ -61,81 +52,122 @@ module Gem
61
52
  require "rubygems/platform"
62
53
 
63
54
  class Platform
64
- JAVA = Gem::Platform.new("java")
65
- MSWIN = Gem::Platform.new("mswin32")
66
- MSWIN64 = Gem::Platform.new("mswin64")
67
- MINGW = Gem::Platform.new("x86-mingw32")
68
- X64_MINGW = [Gem::Platform.new("x64-mingw32"),
69
- Gem::Platform.new("x64-mingw-ucrt")].freeze
70
- UNIVERSAL_MINGW = Gem::Platform.new("universal-mingw")
71
- WINDOWS = [MSWIN, MSWIN64, UNIVERSAL_MINGW].flatten.freeze
72
- X64_LINUX = Gem::Platform.new("x86_64-linux")
73
- X64_LINUX_MUSL = Gem::Platform.new("x86_64-linux-musl")
74
-
75
- if X64_LINUX === X64_LINUX_MUSL
76
- remove_method :===
77
-
78
- def ===(other)
79
- return nil unless Gem::Platform === other
80
-
81
- # universal-mingw32 matches x64-mingw-ucrt
82
- return true if (@cpu == "universal" || other.cpu == "universal") &&
83
- @os.start_with?("mingw") && other.os.start_with?("mingw")
84
-
85
- # cpu
86
- ([nil,"universal"].include?(@cpu) || [nil, "universal"].include?(other.cpu) || @cpu == other.cpu ||
87
- (@cpu == "arm" && other.cpu.start_with?("armv"))) &&
88
-
89
- # os
90
- @os == other.os &&
91
-
92
- # version
93
- (
94
- (@os != "linux" && (@version.nil? || other.version.nil?)) ||
95
- (@os == "linux" && (normalized_linux_version_ext == other.normalized_linux_version_ext || ["musl#{@version}", "musleabi#{@version}", "musleabihf#{@version}"].include?(other.version))) ||
96
- @version == other.version
97
- )
98
- end
55
+ # Can be removed once RubyGems 3.6.9 support is dropped
56
+ unless respond_to?(:generic)
57
+ JAVA = Gem::Platform.new("java") # :nodoc:
58
+ MSWIN = Gem::Platform.new("mswin32") # :nodoc:
59
+ MSWIN64 = Gem::Platform.new("mswin64") # :nodoc:
60
+ MINGW = Gem::Platform.new("x86-mingw32") # :nodoc:
61
+ X64_MINGW_LEGACY = Gem::Platform.new("x64-mingw32") # :nodoc:
62
+ X64_MINGW = Gem::Platform.new("x64-mingw-ucrt") # :nodoc:
63
+ UNIVERSAL_MINGW = Gem::Platform.new("universal-mingw") # :nodoc:
64
+ WINDOWS = [MSWIN, MSWIN64, UNIVERSAL_MINGW].freeze # :nodoc:
65
+ X64_LINUX = Gem::Platform.new("x86_64-linux") # :nodoc:
66
+ X64_LINUX_MUSL = Gem::Platform.new("x86_64-linux-musl") # :nodoc:
67
+
68
+ GENERICS = [JAVA, *WINDOWS].freeze # :nodoc:
69
+ private_constant :GENERICS
70
+
71
+ GENERIC_CACHE = GENERICS.each_with_object({}) {|g, h| h[g] = g } # :nodoc:
72
+ private_constant :GENERIC_CACHE
99
73
 
100
- # This is a copy of RubyGems 3.3.23 or higher `normalized_linux_method`.
101
- # Once only 3.3.23 is supported, we can use the method in RubyGems.
102
- def normalized_linux_version_ext
103
- return nil unless @version
74
+ class << self
75
+ ##
76
+ # Returns the generic platform for the given platform.
104
77
 
105
- without_gnu_nor_abi_modifiers = @version.sub(/\Agnu/, "").sub(/eabi(hf)?\Z/, "")
106
- return nil if without_gnu_nor_abi_modifiers.empty?
78
+ def generic(platform)
79
+ return Gem::Platform::RUBY if platform.nil? || platform == Gem::Platform::RUBY
107
80
 
108
- without_gnu_nor_abi_modifiers
109
- end
110
- end
111
- end
81
+ GENERIC_CACHE[platform] ||= begin
82
+ found = GENERICS.find do |match|
83
+ platform === match
84
+ end
85
+ found || Gem::Platform::RUBY
86
+ end
87
+ end
112
88
 
113
- Platform.singleton_class.module_eval do
114
- unless Platform.singleton_methods.include?(:match_spec?)
115
- def match_spec?(spec)
116
- match_gem?(spec.platform, spec.name)
117
- end
89
+ ##
90
+ # Returns the platform specificity match for the given spec platform and user platform.
118
91
 
119
- def match_gem?(platform, gem_name)
120
- match_platforms?(platform, Gem.platforms)
121
- end
122
- end
92
+ def platform_specificity_match(spec_platform, user_platform)
93
+ return -1 if spec_platform == user_platform
94
+ return 1_000_000 if spec_platform.nil? || spec_platform == Gem::Platform::RUBY || user_platform == Gem::Platform::RUBY
95
+
96
+ os_match(spec_platform, user_platform) +
97
+ cpu_match(spec_platform, user_platform) * 10 +
98
+ version_match(spec_platform, user_platform) * 100
99
+ end
100
+
101
+ ##
102
+ # Sorts and filters the best platform match for the given matching specs and platform.
123
103
 
124
- match_platforms_defined = Gem::Platform.respond_to?(:match_platforms?, true)
104
+ def sort_and_filter_best_platform_match(matching, platform)
105
+ return matching if matching.one?
125
106
 
126
- if !match_platforms_defined || Gem::Platform.send(:match_platforms?, Gem::Platform::X64_LINUX_MUSL, [Gem::Platform::X64_LINUX])
107
+ exact = matching.select {|spec| spec.platform == platform }
108
+ return exact if exact.any?
127
109
 
128
- private
110
+ sorted_matching = sort_best_platform_match(matching, platform)
111
+ exemplary_spec = sorted_matching.first
129
112
 
130
- remove_method :match_platforms? if match_platforms_defined
113
+ sorted_matching.take_while {|spec| same_specificity?(platform, spec, exemplary_spec) && same_deps?(spec, exemplary_spec) }
114
+ end
115
+
116
+ ##
117
+ # Sorts the best platform match for the given matching specs and platform.
118
+
119
+ def sort_best_platform_match(matching, platform)
120
+ matching.sort_by.with_index do |spec, i|
121
+ [
122
+ platform_specificity_match(spec.platform, platform),
123
+ i, # for stable sort
124
+ ]
125
+ end
126
+ end
127
+
128
+ private
129
+
130
+ def same_specificity?(platform, spec, exemplary_spec)
131
+ platform_specificity_match(spec.platform, platform) == platform_specificity_match(exemplary_spec.platform, platform)
132
+ end
131
133
 
132
- def match_platforms?(platform, platforms)
133
- platforms.any? do |local_platform|
134
- platform.nil? ||
135
- local_platform == platform ||
136
- (local_platform != Gem::Platform::RUBY && platform =~ local_platform)
134
+ def same_deps?(spec, exemplary_spec)
135
+ spec.required_ruby_version == exemplary_spec.required_ruby_version &&
136
+ spec.required_rubygems_version == exemplary_spec.required_rubygems_version &&
137
+ spec.dependencies.sort == exemplary_spec.dependencies.sort
138
+ end
139
+
140
+ def os_match(spec_platform, user_platform)
141
+ if spec_platform.os == user_platform.os
142
+ 0
143
+ else
144
+ 1
145
+ end
146
+ end
147
+
148
+ def cpu_match(spec_platform, user_platform)
149
+ if spec_platform.cpu == user_platform.cpu
150
+ 0
151
+ elsif spec_platform.cpu == "arm" && user_platform.cpu.to_s.start_with?("arm")
152
+ 0
153
+ elsif spec_platform.cpu.nil? || spec_platform.cpu == "universal"
154
+ 1
155
+ else
156
+ 2
157
+ end
158
+ end
159
+
160
+ def version_match(spec_platform, user_platform)
161
+ if spec_platform.version == user_platform.version
162
+ 0
163
+ elsif spec_platform.version.nil?
164
+ 1
165
+ else
166
+ 2
167
+ end
137
168
  end
138
169
  end
170
+
139
171
  end
140
172
  end
141
173
 
@@ -144,9 +176,6 @@ module Gem
144
176
  # Can be removed once RubyGems 3.5.14 support is dropped
145
177
  VALIDATES_FOR_RESOLUTION = Specification.new.respond_to?(:validate_for_resolution).freeze
146
178
 
147
- # Can be removed once RubyGems 3.3.15 support is dropped
148
- FLATTENS_REQUIRED_PATHS = Specification.new.respond_to?(:flatten_require_paths).freeze
149
-
150
179
  class Specification
151
180
  # Can be removed once RubyGems 3.5.15 support is dropped
152
181
  correct_array_attributes = @@default_value.select {|_k,v| v.is_a?(Array) }.keys
@@ -158,7 +187,6 @@ module Gem
158
187
  require_relative "match_platform"
159
188
 
160
189
  include ::Bundler::MatchMetadata
161
- include ::Bundler::MatchPlatform
162
190
 
163
191
  attr_accessor :remote, :relative_loaded_from
164
192
 
@@ -214,23 +242,6 @@ module Gem
214
242
  full_gem_path
215
243
  end
216
244
 
217
- unless const_defined?(:LATEST_RUBY_WITHOUT_PATCH_VERSIONS)
218
- LATEST_RUBY_WITHOUT_PATCH_VERSIONS = Gem::Version.new("2.1")
219
-
220
- alias_method :rg_required_ruby_version=, :required_ruby_version=
221
- def required_ruby_version=(req)
222
- self.rg_required_ruby_version = req
223
-
224
- @required_ruby_version.requirements.map! do |op, v|
225
- if v >= LATEST_RUBY_WITHOUT_PATCH_VERSIONS && v.release.segments.size == 4
226
- [op == "~>" ? "=" : op, Gem::Version.new(v.segments.tap {|s| s.delete_at(3) }.join("."))]
227
- else
228
- [op, v]
229
- end
230
- end
231
- end
232
- end
233
-
234
245
  def insecurely_materialized?
235
246
  false
236
247
  end
@@ -272,25 +283,16 @@ module Gem
272
283
  end
273
284
  end
274
285
 
275
- unless FLATTENS_REQUIRED_PATHS
276
- def flatten_require_paths
277
- return unless raw_require_paths.first.is_a?(Array)
278
-
279
- warn "#{name} #{version} includes a gemspec with `require_paths` set to an array of arrays. Newer versions of this gem might've already fixed this"
280
- raw_require_paths.flatten!
281
- end
286
+ if Gem.rubygems_version < Gem::Version.new("3.5.22")
287
+ module FixPathSourceMissingExtensions
288
+ def missing_extensions?
289
+ return false if %w[Bundler::Source::Path Bundler::Source::Gemspec].include?(source.class.name)
282
290
 
283
- class << self
284
- module RequirePathFlattener
285
- def from_yaml(input)
286
- spec = super(input)
287
- spec.flatten_require_paths
288
- spec
289
- end
291
+ super
290
292
  end
291
-
292
- prepend RequirePathFlattener
293
293
  end
294
+
295
+ prepend FixPathSourceMissingExtensions
294
296
  end
295
297
 
296
298
  private
@@ -401,6 +403,11 @@ module Gem
401
403
  @ignored = missing_extensions?
402
404
  end
403
405
  end
406
+
407
+ # Can be removed once RubyGems 3.6.9 support is dropped
408
+ unless new.respond_to?(:installable_on_platform?)
409
+ include(::Bundler::MatchPlatform)
410
+ end
404
411
  end
405
412
 
406
413
  require "rubygems/name_tuple"
@@ -471,15 +478,4 @@ module Gem
471
478
 
472
479
  Package::TarReader::Entry.prepend(FixFullNameEncoding)
473
480
  end
474
-
475
- require "rubygems/uri"
476
-
477
- # Can be removed once RubyGems 3.3.15 support is dropped
478
- unless Gem::Uri.respond_to?(:redact)
479
- class Uri
480
- def self.redact(uri)
481
- new(uri).redacted
482
- end
483
- end
484
- end
485
481
  end