bundler 2.5.11 → 2.5.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +84 -0
  3. data/lib/bundler/build_metadata.rb +2 -2
  4. data/lib/bundler/cli/check.rb +1 -1
  5. data/lib/bundler/cli/fund.rb +1 -1
  6. data/lib/bundler/cli/gem.rb +8 -15
  7. data/lib/bundler/cli.rb +26 -26
  8. data/lib/bundler/compact_index_client/cache.rb +47 -81
  9. data/lib/bundler/compact_index_client/parser.rb +84 -0
  10. data/lib/bundler/compact_index_client.rb +51 -80
  11. data/lib/bundler/definition.rb +50 -24
  12. data/lib/bundler/endpoint_specification.rb +11 -0
  13. data/lib/bundler/env.rb +1 -1
  14. data/lib/bundler/fetcher/compact_index.rb +15 -24
  15. data/lib/bundler/force_platform.rb +0 -2
  16. data/lib/bundler/gem_helpers.rb +14 -7
  17. data/lib/bundler/injector.rb +1 -4
  18. data/lib/bundler/installer/gem_installer.rb +0 -1
  19. data/lib/bundler/installer/standalone.rb +0 -3
  20. data/lib/bundler/installer.rb +1 -3
  21. data/lib/bundler/lazy_specification.rb +1 -0
  22. data/lib/bundler/man/bundle-add.1 +1 -1
  23. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  24. data/lib/bundler/man/bundle-cache.1 +1 -1
  25. data/lib/bundler/man/bundle-check.1 +1 -1
  26. data/lib/bundler/man/bundle-clean.1 +1 -1
  27. data/lib/bundler/man/bundle-config.1 +2 -2
  28. data/lib/bundler/man/bundle-config.1.ronn +1 -1
  29. data/lib/bundler/man/bundle-console.1 +1 -1
  30. data/lib/bundler/man/bundle-doctor.1 +1 -1
  31. data/lib/bundler/man/bundle-exec.1 +1 -1
  32. data/lib/bundler/man/bundle-gem.1 +7 -1
  33. data/lib/bundler/man/bundle-gem.1.ronn +11 -0
  34. data/lib/bundler/man/bundle-help.1 +1 -1
  35. data/lib/bundler/man/bundle-info.1 +1 -1
  36. data/lib/bundler/man/bundle-init.1 +1 -1
  37. data/lib/bundler/man/bundle-inject.1 +1 -1
  38. data/lib/bundler/man/bundle-install.1 +1 -1
  39. data/lib/bundler/man/bundle-list.1 +1 -1
  40. data/lib/bundler/man/bundle-lock.1 +1 -1
  41. data/lib/bundler/man/bundle-open.1 +1 -1
  42. data/lib/bundler/man/bundle-outdated.1 +1 -1
  43. data/lib/bundler/man/bundle-platform.1 +1 -1
  44. data/lib/bundler/man/bundle-plugin.1 +1 -1
  45. data/lib/bundler/man/bundle-pristine.1 +1 -1
  46. data/lib/bundler/man/bundle-remove.1 +1 -1
  47. data/lib/bundler/man/bundle-show.1 +1 -1
  48. data/lib/bundler/man/bundle-update.1 +1 -1
  49. data/lib/bundler/man/bundle-version.1 +1 -1
  50. data/lib/bundler/man/bundle-viz.1 +1 -1
  51. data/lib/bundler/man/bundle.1 +1 -1
  52. data/lib/bundler/man/gemfile.5 +1 -1
  53. data/lib/bundler/plugin/api/source.rb +1 -0
  54. data/lib/bundler/resolver/base.rb +4 -0
  55. data/lib/bundler/resolver/candidate.rb +4 -16
  56. data/lib/bundler/resolver/package.rb +4 -0
  57. data/lib/bundler/resolver/spec_group.rb +20 -2
  58. data/lib/bundler/resolver.rb +18 -9
  59. data/lib/bundler/rubygems_ext.rb +76 -14
  60. data/lib/bundler/rubygems_gem_installer.rb +35 -2
  61. data/lib/bundler/rubygems_integration.rb +16 -2
  62. data/lib/bundler/runtime.rb +1 -6
  63. data/lib/bundler/self_manager.rb +22 -2
  64. data/lib/bundler/settings.rb +12 -8
  65. data/lib/bundler/setup.rb +3 -0
  66. data/lib/bundler/shared_helpers.rb +2 -2
  67. data/lib/bundler/source/git.rb +43 -16
  68. data/lib/bundler/source/path.rb +0 -13
  69. data/lib/bundler/source/rubygems.rb +26 -13
  70. data/lib/bundler/spec_set.rb +15 -13
  71. data/lib/bundler/stub_specification.rb +8 -0
  72. data/lib/bundler/vendored_net_http.rb +17 -6
  73. data/lib/bundler/version.rb +1 -1
  74. data/lib/bundler/yaml_serializer.rb +2 -9
  75. data/lib/bundler.rb +6 -1
  76. metadata +4 -3
@@ -1,6 +1,6 @@
1
1
  .\" generated with nRonn/v0.11.1
2
2
  .\" https://github.com/n-ronn/nronn/tree/0.11.1
3
- .TH "BUNDLE\-GEM" "1" "May 2024" ""
3
+ .TH "BUNDLE\-GEM" "1" "June 2024" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-gem\fR \- Generate a project skeleton for creating a rubygem
6
6
  .SH "SYNOPSIS"
@@ -44,6 +44,8 @@ When Bundler is configured to not generate tests, an interactive prompt will be
44
44
  .IP
45
45
  When Bundler is unconfigured, an interactive prompt will be displayed and the answer will be saved in Bundler's global config for future \fBbundle gem\fR use\.
46
46
  .IP "\(bu" 4
47
+ \fB\-\-no\-test\fR: Do not use a test framework (overrides \fB\-\-test\fR specified in the global config)\.
48
+ .IP "\(bu" 4
47
49
  \fB\-\-ci\fR, \fB\-\-ci=github\fR, \fB\-\-ci=gitlab\fR, \fB\-\-ci=circle\fR: Specify the continuous integration service that Bundler should use when generating the project\. Acceptable values are \fBgithub\fR, \fBgitlab\fR and \fBcircle\fR\. A configuration file will be generated in the project directory\. Given no option is specified:
48
50
  .IP
49
51
  When Bundler is configured to generate CI files, this defaults to Bundler's global config setting \fBgem\.ci\fR\.
@@ -52,6 +54,8 @@ When Bundler is configured to not generate CI files, an interactive prompt will
52
54
  .IP
53
55
  When Bundler is unconfigured, an interactive prompt will be displayed and the answer will be saved in Bundler's global config for future \fBbundle gem\fR use\.
54
56
  .IP "\(bu" 4
57
+ \fB\-\-no\-ci\fR: Do not use a continuous integration service (overrides \fB\-\-ci\fR specified in the global config)\.
58
+ .IP "\(bu" 4
55
59
  \fB\-\-linter\fR, \fB\-\-linter=rubocop\fR, \fB\-\-linter=standard\fR: Specify the linter and code formatter that Bundler should add to the project's development dependencies\. Acceptable values are \fBrubocop\fR and \fBstandard\fR\. A configuration file will be generated in the project directory\. Given no option is specified:
56
60
  .IP
57
61
  When Bundler is configured to add a linter, this defaults to Bundler's global config setting \fBgem\.linter\fR\.
@@ -60,6 +64,8 @@ When Bundler is configured not to add a linter, an interactive prompt will be di
60
64
  .IP
61
65
  When Bundler is unconfigured, an interactive prompt will be displayed and the answer will be saved in Bundler's global config for future \fBbundle gem\fR use\.
62
66
  .IP "\(bu" 4
67
+ \fB\-\-no\-linter\fR: Do not add a linter (overrides \fB\-\-linter\fR specified in the global config)\.
68
+ .IP "\(bu" 4
63
69
  \fB\-e\fR, \fB\-\-edit[=EDITOR]\fR: Open the resulting GEM_NAME\.gemspec in EDITOR, or the default editor if not specified\. The default is \fB$BUNDLER_EDITOR\fR, \fB$VISUAL\fR, or \fB$EDITOR\fR\.
64
70
  .IP "" 0
65
71
  .SH "SEE ALSO"
@@ -76,6 +76,10 @@ configuration file using the following names:
76
76
  the answer will be saved in Bundler's global config for future `bundle gem`
77
77
  use.
78
78
 
79
+ * `--no-test`:
80
+ Do not use a test framework (overrides `--test` specified in the global
81
+ config).
82
+
79
83
  * `--ci`, `--ci=github`, `--ci=gitlab`, `--ci=circle`:
80
84
  Specify the continuous integration service that Bundler should use when
81
85
  generating the project. Acceptable values are `github`, `gitlab`
@@ -92,6 +96,10 @@ configuration file using the following names:
92
96
  the answer will be saved in Bundler's global config for future `bundle gem`
93
97
  use.
94
98
 
99
+ * `--no-ci`:
100
+ Do not use a continuous integration service (overrides `--ci` specified in
101
+ the global config).
102
+
95
103
  * `--linter`, `--linter=rubocop`, `--linter=standard`:
96
104
  Specify the linter and code formatter that Bundler should add to the
97
105
  project's development dependencies. Acceptable values are `rubocop` and
@@ -108,6 +116,9 @@ configuration file using the following names:
108
116
  the answer will be saved in Bundler's global config for future `bundle gem`
109
117
  use.
110
118
 
119
+ * `--no-linter`:
120
+ Do not add a linter (overrides `--linter` specified in the global config).
121
+
111
122
  * `-e`, `--edit[=EDITOR]`:
112
123
  Open the resulting GEM_NAME.gemspec in EDITOR, or the default editor if not
113
124
  specified. The default is `$BUNDLER_EDITOR`, `$VISUAL`, or `$EDITOR`.
@@ -1,6 +1,6 @@
1
1
  .\" generated with nRonn/v0.11.1
2
2
  .\" https://github.com/n-ronn/nronn/tree/0.11.1
3
- .TH "BUNDLE\-HELP" "1" "May 2024" ""
3
+ .TH "BUNDLE\-HELP" "1" "June 2024" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-help\fR \- Displays detailed help for each subcommand
6
6
  .SH "SYNOPSIS"
@@ -1,6 +1,6 @@
1
1
  .\" generated with nRonn/v0.11.1
2
2
  .\" https://github.com/n-ronn/nronn/tree/0.11.1
3
- .TH "BUNDLE\-INFO" "1" "May 2024" ""
3
+ .TH "BUNDLE\-INFO" "1" "June 2024" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-info\fR \- Show information for the given gem in your bundle
6
6
  .SH "SYNOPSIS"
@@ -1,6 +1,6 @@
1
1
  .\" generated with nRonn/v0.11.1
2
2
  .\" https://github.com/n-ronn/nronn/tree/0.11.1
3
- .TH "BUNDLE\-INIT" "1" "May 2024" ""
3
+ .TH "BUNDLE\-INIT" "1" "June 2024" ""
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 nRonn/v0.11.1
2
2
  .\" https://github.com/n-ronn/nronn/tree/0.11.1
3
- .TH "BUNDLE\-INJECT" "1" "May 2024" ""
3
+ .TH "BUNDLE\-INJECT" "1" "June 2024" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-inject\fR \- Add named gem(s) with version requirements to Gemfile
6
6
  .SH "SYNOPSIS"
@@ -1,6 +1,6 @@
1
1
  .\" generated with nRonn/v0.11.1
2
2
  .\" https://github.com/n-ronn/nronn/tree/0.11.1
3
- .TH "BUNDLE\-INSTALL" "1" "May 2024" ""
3
+ .TH "BUNDLE\-INSTALL" "1" "June 2024" ""
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 nRonn/v0.11.1
2
2
  .\" https://github.com/n-ronn/nronn/tree/0.11.1
3
- .TH "BUNDLE\-LIST" "1" "May 2024" ""
3
+ .TH "BUNDLE\-LIST" "1" "June 2024" ""
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 nRonn/v0.11.1
2
2
  .\" https://github.com/n-ronn/nronn/tree/0.11.1
3
- .TH "BUNDLE\-LOCK" "1" "May 2024" ""
3
+ .TH "BUNDLE\-LOCK" "1" "June 2024" ""
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 nRonn/v0.11.1
2
2
  .\" https://github.com/n-ronn/nronn/tree/0.11.1
3
- .TH "BUNDLE\-OPEN" "1" "May 2024" ""
3
+ .TH "BUNDLE\-OPEN" "1" "June 2024" ""
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 nRonn/v0.11.1
2
2
  .\" https://github.com/n-ronn/nronn/tree/0.11.1
3
- .TH "BUNDLE\-OUTDATED" "1" "May 2024" ""
3
+ .TH "BUNDLE\-OUTDATED" "1" "June 2024" ""
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 nRonn/v0.11.1
2
2
  .\" https://github.com/n-ronn/nronn/tree/0.11.1
3
- .TH "BUNDLE\-PLATFORM" "1" "May 2024" ""
3
+ .TH "BUNDLE\-PLATFORM" "1" "June 2024" ""
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 nRonn/v0.11.1
2
2
  .\" https://github.com/n-ronn/nronn/tree/0.11.1
3
- .TH "BUNDLE\-PLUGIN" "1" "May 2024" ""
3
+ .TH "BUNDLE\-PLUGIN" "1" "June 2024" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\-plugin\fR \- Manage Bundler plugins
6
6
  .SH "SYNOPSIS"
@@ -1,6 +1,6 @@
1
1
  .\" generated with nRonn/v0.11.1
2
2
  .\" https://github.com/n-ronn/nronn/tree/0.11.1
3
- .TH "BUNDLE\-PRISTINE" "1" "May 2024" ""
3
+ .TH "BUNDLE\-PRISTINE" "1" "June 2024" ""
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 nRonn/v0.11.1
2
2
  .\" https://github.com/n-ronn/nronn/tree/0.11.1
3
- .TH "BUNDLE\-REMOVE" "1" "May 2024" ""
3
+ .TH "BUNDLE\-REMOVE" "1" "June 2024" ""
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 nRonn/v0.11.1
2
2
  .\" https://github.com/n-ronn/nronn/tree/0.11.1
3
- .TH "BUNDLE\-SHOW" "1" "May 2024" ""
3
+ .TH "BUNDLE\-SHOW" "1" "June 2024" ""
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 nRonn/v0.11.1
2
2
  .\" https://github.com/n-ronn/nronn/tree/0.11.1
3
- .TH "BUNDLE\-UPDATE" "1" "May 2024" ""
3
+ .TH "BUNDLE\-UPDATE" "1" "June 2024" ""
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 nRonn/v0.11.1
2
2
  .\" https://github.com/n-ronn/nronn/tree/0.11.1
3
- .TH "BUNDLE\-VERSION" "1" "May 2024" ""
3
+ .TH "BUNDLE\-VERSION" "1" "June 2024" ""
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 nRonn/v0.11.1
2
2
  .\" https://github.com/n-ronn/nronn/tree/0.11.1
3
- .TH "BUNDLE\-VIZ" "1" "May 2024" ""
3
+ .TH "BUNDLE\-VIZ" "1" "June 2024" ""
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 nRonn/v0.11.1
2
2
  .\" https://github.com/n-ronn/nronn/tree/0.11.1
3
- .TH "BUNDLE" "1" "May 2024" ""
3
+ .TH "BUNDLE" "1" "June 2024" ""
4
4
  .SH "NAME"
5
5
  \fBbundle\fR \- Ruby Dependency Management
6
6
  .SH "SYNOPSIS"
@@ -1,6 +1,6 @@
1
1
  .\" generated with nRonn/v0.11.1
2
2
  .\" https://github.com/n-ronn/nronn/tree/0.11.1
3
- .TH "GEMFILE" "5" "May 2024" ""
3
+ .TH "GEMFILE" "5" "June 2024" ""
4
4
  .SH "NAME"
5
5
  \fBGemfile\fR \- A format for describing gem dependencies for Ruby programs
6
6
  .SH "SYNOPSIS"
@@ -196,6 +196,7 @@ module Bundler
196
196
 
197
197
  FileUtils.rm_rf(new_cache_path)
198
198
  FileUtils.cp_r(install_path, new_cache_path)
199
+ FileUtils.rm_rf(app_cache_path.join(".git"))
199
200
  FileUtils.touch(app_cache_path.join(".bundlecache"))
200
201
  end
201
202
 
@@ -30,6 +30,10 @@ module Bundler
30
30
  end.compact
31
31
  end
32
32
 
33
+ def specs_compatible_with(result)
34
+ @base.specs_compatible_with(result)
35
+ end
36
+
33
37
  def [](name)
34
38
  @base[name]
35
39
  end
@@ -24,10 +24,10 @@ module Bundler
24
24
 
25
25
  attr_reader :version
26
26
 
27
- def initialize(version, specs: [])
28
- @spec_group = Resolver::SpecGroup.new(specs)
27
+ def initialize(version, group: nil, priority: -1)
28
+ @spec_group = group || SpecGroup.new([])
29
29
  @version = Gem::Version.new(version)
30
- @ruby_only = specs.map(&:platform).uniq == [Gem::Platform::RUBY]
30
+ @priority = priority
31
31
  end
32
32
 
33
33
  def dependencies
@@ -40,18 +40,6 @@ module Bundler
40
40
  @spec_group.to_specs(package.force_ruby_platform?)
41
41
  end
42
42
 
43
- def generic!
44
- @ruby_only = true
45
-
46
- self
47
- end
48
-
49
- def platform_specific!
50
- @ruby_only = false
51
-
52
- self
53
- end
54
-
55
43
  def prerelease?
56
44
  @version.prerelease?
57
45
  end
@@ -61,7 +49,7 @@ module Bundler
61
49
  end
62
50
 
63
51
  def sort_obj
64
- [@version, @ruby_only ? -1 : 1]
52
+ [@version, @priority]
65
53
  end
66
54
 
67
55
  def <=>(other)
@@ -25,6 +25,10 @@ module Bundler
25
25
  @prerelease = @dependency.prerelease? || @locked_version&.prerelease? || prerelease ? :consider_first : :ignore
26
26
  end
27
27
 
28
+ def platform_specs(specs)
29
+ platforms.map {|platform| GemHelpers.select_best_platform_match(specs, platform, prefer_locked: !unlock?) }
30
+ end
31
+
28
32
  def to_s
29
33
  @name.delete("\0")
30
34
  end
@@ -3,6 +3,8 @@
3
3
  module Bundler
4
4
  class Resolver
5
5
  class SpecGroup
6
+ attr_reader :specs
7
+
6
8
  def initialize(specs)
7
9
  @specs = specs
8
10
  end
@@ -38,17 +40,33 @@ module Bundler
38
40
  def dependencies
39
41
  @dependencies ||= @specs.map do |spec|
40
42
  __dependencies(spec) + metadata_dependencies(spec)
41
- end.flatten.uniq
43
+ end.flatten.uniq.sort
44
+ end
45
+
46
+ def ==(other)
47
+ sorted_spec_names == other.sorted_spec_names
48
+ end
49
+
50
+ def merge(other)
51
+ return false unless equivalent?(other)
52
+
53
+ @specs |= other.specs
54
+
55
+ true
42
56
  end
43
57
 
44
58
  protected
45
59
 
46
60
  def sorted_spec_names
47
- @sorted_spec_names ||= @specs.map(&:full_name).sort
61
+ @specs.map(&:full_name).sort
48
62
  end
49
63
 
50
64
  private
51
65
 
66
+ def equivalent?(other)
67
+ name == other.name && version == other.version && source == other.source && dependencies == other.dependencies
68
+ end
69
+
52
70
  def exemplary_spec
53
71
  @specs.first
54
72
  end
@@ -79,7 +79,8 @@ module Bundler
79
79
  def solve_versions(root:, logger:)
80
80
  solver = PubGrub::VersionSolver.new(source: self, root: root, logger: logger)
81
81
  result = solver.solve
82
- result.map {|package, version| version.to_specs(package) }.flatten.uniq
82
+ resolved_specs = result.map {|package, version| version.to_specs(package) }.flatten
83
+ resolved_specs |= @base.specs_compatible_with(SpecSet.new(resolved_specs))
83
84
  rescue PubGrub::SolveFailure => e
84
85
  incompatibility = e.incompatibility
85
86
 
@@ -254,7 +255,7 @@ module Bundler
254
255
  results = filter_matching_specs(results, locked_requirement) if locked_requirement
255
256
 
256
257
  results.group_by(&:version).reduce([]) do |groups, (version, specs)|
257
- platform_specs = package.platforms.map {|platform| select_best_platform_match(specs, platform) }
258
+ platform_specs = package.platform_specs(specs)
258
259
 
259
260
  # If package is a top-level dependency,
260
261
  # candidate is only valid if there are matching versions for all resolution platforms.
@@ -269,14 +270,22 @@ module Bundler
269
270
  next groups if platform_specs.all?(&:empty?)
270
271
  end
271
272
 
272
- platform_specs.flatten!
273
-
274
273
  ruby_specs = select_best_platform_match(specs, Gem::Platform::RUBY)
275
- groups << Resolver::Candidate.new(version, specs: ruby_specs) if ruby_specs.any?
274
+ ruby_group = Resolver::SpecGroup.new(ruby_specs)
275
+
276
+ unless ruby_group.empty?
277
+ platform_specs.each do |specs|
278
+ ruby_group.merge(Resolver::SpecGroup.new(specs))
279
+ end
280
+
281
+ groups << Resolver::Candidate.new(version, group: ruby_group, priority: -1)
282
+ next groups if package.force_ruby_platform?
283
+ end
276
284
 
277
- next groups if platform_specs == ruby_specs || package.force_ruby_platform?
285
+ platform_group = Resolver::SpecGroup.new(platform_specs.flatten.uniq)
286
+ next groups if platform_group == ruby_group
278
287
 
279
- groups << Resolver::Candidate.new(version, specs: platform_specs)
288
+ groups << Resolver::Candidate.new(version, group: platform_group, priority: 1)
280
289
 
281
290
  groups
282
291
  end
@@ -431,8 +440,8 @@ module Bundler
431
440
 
432
441
  def requirement_to_range(requirement)
433
442
  ranges = requirement.requirements.map do |(op, version)|
434
- ver = Resolver::Candidate.new(version).generic!
435
- platform_ver = Resolver::Candidate.new(version).platform_specific!
443
+ ver = Resolver::Candidate.new(version, priority: -1)
444
+ platform_ver = Resolver::Candidate.new(version, priority: 1)
436
445
 
437
446
  case op
438
447
  when "~>"
@@ -30,9 +30,42 @@ module Gem
30
30
  end
31
31
  end
32
32
 
33
+ # Can be removed once RubyGems 3.5.14 support is dropped
34
+ unless Gem.respond_to?(:open_file_with_flock)
35
+ def self.open_file_with_flock(path, &block)
36
+ flags = File.exist?(path) ? "r+" : "a+"
37
+
38
+ File.open(path, flags) do |io|
39
+ begin
40
+ io.flock(File::LOCK_EX)
41
+ rescue Errno::ENOSYS, Errno::ENOTSUP
42
+ end
43
+ yield io
44
+ rescue Errno::ENOLCK # NFS
45
+ if Thread.main != Thread.current
46
+ raise
47
+ else
48
+ File.open(path, flags, &block)
49
+ end
50
+ end
51
+ end
52
+ end
53
+
33
54
  require "rubygems/specification"
34
55
 
56
+ # Can be removed once RubyGems 3.5.14 support is dropped
57
+ VALIDATES_FOR_RESOLUTION = Specification.new.respond_to?(:validate_for_resolution).freeze
58
+
59
+ # Can be removed once RubyGems 3.3.15 support is dropped
60
+ FLATTENS_REQUIRED_PATHS = Specification.new.respond_to?(:flatten_require_paths).freeze
61
+
35
62
  class Specification
63
+ # Can be removed once RubyGems 3.5.15 support is dropped
64
+ correct_array_attributes = @@default_value.select {|_k,v| v.is_a?(Array) }.keys
65
+ unless @@array_attributes == correct_array_attributes
66
+ @@array_attributes = correct_array_attributes # rubocop:disable Style/ClassVars
67
+ end
68
+
36
69
  require_relative "match_metadata"
37
70
  require_relative "match_platform"
38
71
 
@@ -131,6 +164,33 @@ module Gem
131
164
  !default_gem? && !File.directory?(full_gem_path)
132
165
  end
133
166
 
167
+ unless VALIDATES_FOR_RESOLUTION
168
+ def validate_for_resolution
169
+ SpecificationPolicy.new(self).validate_for_resolution
170
+ end
171
+ end
172
+
173
+ unless FLATTENS_REQUIRED_PATHS
174
+ def flatten_require_paths
175
+ return unless raw_require_paths.first.is_a?(Array)
176
+
177
+ 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"
178
+ raw_require_paths.flatten!
179
+ end
180
+
181
+ class << self
182
+ module RequirePathFlattener
183
+ def from_yaml(input)
184
+ spec = super(input)
185
+ spec.flatten_require_paths
186
+ spec
187
+ end
188
+ end
189
+
190
+ prepend RequirePathFlattener
191
+ end
192
+ end
193
+
134
194
  private
135
195
 
136
196
  def dependencies_to_gemfile(dependencies, group = nil)
@@ -150,6 +210,14 @@ module Gem
150
210
  end
151
211
  end
152
212
 
213
+ unless VALIDATES_FOR_RESOLUTION
214
+ class SpecificationPolicy
215
+ def validate_for_resolution
216
+ validate_required!
217
+ end
218
+ end
219
+ end
220
+
153
221
  module BetterPermissionError
154
222
  def data
155
223
  super
@@ -169,26 +237,20 @@ module Gem
169
237
 
170
238
  include ::Bundler::ForcePlatform
171
239
 
240
+ attr_reader :force_ruby_platform
241
+
172
242
  attr_accessor :source, :groups
173
243
 
174
244
  alias_method :eql?, :==
175
245
 
176
- def force_ruby_platform
177
- return @force_ruby_platform if defined?(@force_ruby_platform) && !@force_ruby_platform.nil?
178
-
179
- @force_ruby_platform = default_force_ruby_platform
180
- end
181
-
182
- def encode_with(coder)
183
- to_yaml_properties.each do |ivar|
184
- coder[ivar.to_s.sub(/^@/, "")] = instance_variable_get(ivar)
246
+ unless method_defined?(:encode_with, false)
247
+ def encode_with(coder)
248
+ [:@name, :@requirement, :@type, :@prerelease, :@version_requirements].each do |ivar|
249
+ coder[ivar.to_s.sub(/^@/, "")] = instance_variable_get(ivar)
250
+ end
185
251
  end
186
252
  end
187
253
 
188
- def to_yaml_properties
189
- instance_variables.reject {|p| ["@source", "@groups"].include?(p.to_s) }
190
- end
191
-
192
254
  def to_lock
193
255
  out = String.new(" #{name}")
194
256
  unless requirement.none?
@@ -241,7 +303,7 @@ module Gem
241
303
 
242
304
  # cpu
243
305
  ([nil,"universal"].include?(@cpu) || [nil, "universal"].include?(other.cpu) || @cpu == other.cpu ||
244
- (@cpu == "arm" && other.cpu.start_with?("arm"))) &&
306
+ (@cpu == "arm" && other.cpu.start_with?("armv"))) &&
245
307
 
246
308
  # os
247
309
  @os == other.os &&
@@ -29,7 +29,10 @@ module Bundler
29
29
  write_build_info_file
30
30
  run_post_build_hooks
31
31
 
32
- generate_bin
32
+ SharedHelpers.filesystem_access(bin_dir, :write) do
33
+ generate_bin
34
+ end
35
+
33
36
  generate_plugins
34
37
 
35
38
  write_spec
@@ -45,7 +48,17 @@ module Bundler
45
48
  spec
46
49
  end
47
50
 
48
- def pre_install_checks
51
+ if Bundler.rubygems.provides?("< 3.5")
52
+ def pre_install_checks
53
+ super
54
+ rescue Gem::FilePermissionError
55
+ # Ignore permission checks in RubyGems. Instead, go on, and try to write
56
+ # for real. We properly handle permission errors when they happen.
57
+ nil
58
+ end
59
+ end
60
+
61
+ def ensure_writable_dir(dir)
49
62
  super
50
63
  rescue Gem::FilePermissionError
51
64
  # Ignore permission checks in RubyGems. Instead, go on, and try to write
@@ -68,6 +81,26 @@ module Bundler
68
81
  end
69
82
  end
70
83
 
84
+ if Bundler.rubygems.provides?("< 3.5.15")
85
+ def generate_bin_script(filename, bindir)
86
+ bin_script_path = File.join bindir, formatted_program_filename(filename)
87
+
88
+ Gem.open_file_with_flock("#{bin_script_path}.lock") do
89
+ require "fileutils"
90
+ FileUtils.rm_f bin_script_path # prior install may have been --no-wrappers
91
+
92
+ File.open(bin_script_path, "wb", 0o755) do |file|
93
+ file.write app_script_text(filename)
94
+ file.chmod(options[:prog_mode] || 0o755)
95
+ end
96
+ end
97
+
98
+ verbose bin_script_path
99
+
100
+ generate_windows_script filename, bindir
101
+ end
102
+ end
103
+
71
104
  def build_extensions
72
105
  extension_cache_path = options[:bundler_extension_cache_path]
73
106
  extension_dir = spec.extension_dir
@@ -48,7 +48,7 @@ module Bundler
48
48
  end
49
49
 
50
50
  def validate(spec)
51
- Bundler.ui.silence { spec.validate(false) }
51
+ Bundler.ui.silence { spec.validate_for_resolution }
52
52
  rescue Gem::InvalidSpecificationException => e
53
53
  error_message = "The gemspec at #{spec.loaded_from} is not valid. Please fix this gemspec.\n" \
54
54
  "The validation error was '#{e.message}'\n"
@@ -204,7 +204,7 @@ module Bundler
204
204
 
205
205
  [::Kernel.singleton_class, ::Kernel].each do |kernel_class|
206
206
  redefine_method(kernel_class, :gem) do |dep, *reqs|
207
- if executables&.include?(File.basename(caller.first.split(":").first))
207
+ if executables&.include?(File.basename(caller_locations(1, 1).first.path))
208
208
  break
209
209
  end
210
210
 
@@ -469,11 +469,25 @@ module Bundler
469
469
  end
470
470
 
471
471
  def all_specs
472
+ SharedHelpers.major_deprecation 2, "Bundler.rubygems.all_specs has been removed in favor of Bundler.rubygems.installed_specs"
473
+
472
474
  Gem::Specification.stubs.map do |stub|
473
475
  StubSpecification.from_stub(stub)
474
476
  end
475
477
  end
476
478
 
479
+ def installed_specs
480
+ Gem::Specification.stubs.reject(&:default_gem?).map do |stub|
481
+ StubSpecification.from_stub(stub)
482
+ end
483
+ end
484
+
485
+ def default_specs
486
+ Gem::Specification.default_stubs.map do |stub|
487
+ StubSpecification.from_stub(stub)
488
+ end
489
+ end
490
+
477
491
  def find_bundler(version)
478
492
  find_name("bundler").find {|s| s.version.to_s == version }
479
493
  end