bundler 2.4.3 → 2.4.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4598d8531bbdd46221e7238ee2aa828683a3e1854e47bf901857f791a01eb969
4
- data.tar.gz: ead0de0789d8d5682c8d58e60da80a245d5710f8358669e544bb915546f3b82c
3
+ metadata.gz: 3c086402f586de5162fbccb5f97175ef0539debc5010faed4a7cd25b94c9a0c1
4
+ data.tar.gz: 5b0c3726de4085c618f785727c4572b70717e390bf7444a07ff44a3b2c46de64
5
5
  SHA512:
6
- metadata.gz: 8078880e8f03117e011bedb3150aba2dfc91c271dfd289ed99f0850e5cb8c62c50af5d7c834c2fc224e17ff925f59e237b33141c1b7d9dec3efdaf35b9f353c1
7
- data.tar.gz: 278df46d98c43489e941b788aca7b3cc46358a3ea099987f83c8cdb3b618ed3b0373d7bea590a80620332316d0b12a0bf98f0d02349c55d769174960f5169a45
6
+ metadata.gz: fee7f484591b307723fad8855c6b76d516648e37a0e51636d67fd642cf65a057a0e48c7ed80588833fb962196694f23644c3965cd5490c6c70f0add41d1d371e
7
+ data.tar.gz: 362ccbe671ea531b2e187c468ec6e841fffe3e500d56d3f99e283623b791c62643d8098d0460c77285d09353009bdd135369ce45746a8da368e696e70cafc45b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ # 2.4.4 (January 16, 2023)
2
+
3
+ ## Bug fixes:
4
+
5
+ - Fix platform specific gems removed from the lockfile [#6266](https://github.com/rubygems/rubygems/pull/6266)
6
+ - Properly handle incompatibilities on platform specific gems [#6270](https://github.com/rubygems/rubygems/pull/6270)
7
+ - Optimistically exclude prereleases from initial resolution [#6246](https://github.com/rubygems/rubygems/pull/6246)
8
+ - Fix another case of not properly falling back to ruby variant when materializing [#6261](https://github.com/rubygems/rubygems/pull/6261)
9
+ - Skip setting `BUNDLER_SETUP` on Ruby 2.6 [#6252](https://github.com/rubygems/rubygems/pull/6252)
10
+ - Let resolver deal with legacy gems with equivalent version and different dependencies [#6219](https://github.com/rubygems/rubygems/pull/6219)
11
+
1
12
  # 2.4.3 (January 6, 2023)
2
13
 
3
14
  ## Enhancements:
@@ -4,8 +4,8 @@ module Bundler
4
4
  # Represents metadata from when the Bundler gem was built.
5
5
  module BuildMetadata
6
6
  # begin ivars
7
- @built_at = "2023-01-06".freeze
8
- @git_commit_sha = "ed1f27f75c".freeze
7
+ @built_at = "2023-01-16".freeze
8
+ @git_commit_sha = "e1c0b50e84".freeze
9
9
  @release = true
10
10
  # end ivars
11
11
 
@@ -159,13 +159,6 @@ module Bundler
159
159
  resolve
160
160
  end
161
161
 
162
- def resolve_prefering_local!
163
- @prefer_local = true
164
- @remote = true
165
- sources.remote!
166
- resolve
167
- end
168
-
169
162
  def resolve_with_cache!
170
163
  sources.cached!
171
164
  resolve
@@ -177,6 +170,23 @@ module Bundler
177
170
  resolve
178
171
  end
179
172
 
173
+ def resolution_mode=(options)
174
+ if options["local"]
175
+ @remote = false
176
+ else
177
+ @remote = true
178
+ @prefer_local = options["prefer-local"]
179
+ end
180
+ end
181
+
182
+ def setup_sources_for_resolve
183
+ if @remote == false
184
+ sources.cached!
185
+ else
186
+ sources.remote!
187
+ end
188
+ end
189
+
180
190
  # For given dependency list returns a SpecSet with Gemspec of all the required
181
191
  # dependencies.
182
192
  # 1. The method first resolves the dependencies specified in Gemfile
@@ -473,11 +483,7 @@ module Bundler
473
483
  private
474
484
 
475
485
  def resolver
476
- @resolver ||= begin
477
- last_resolve = converge_locked_specs
478
- remove_ruby_from_platforms_if_necessary!(current_dependencies)
479
- Resolver.new(source_requirements, last_resolve, gem_version_promoter, additional_base_requirements_for_resolve(last_resolve))
480
- end
486
+ @resolver ||= Resolver.new(resolution_packages, gem_version_promoter)
481
487
  end
482
488
 
483
489
  def expanded_dependencies
@@ -486,18 +492,10 @@ module Bundler
486
492
 
487
493
  def resolution_packages
488
494
  @resolution_packages ||= begin
489
- packages = Hash.new do |h, k|
490
- h[k] = Resolver::Package.new(k, @platforms, @originally_locked_specs, @unlock[:gems])
491
- end
492
-
493
- expanded_dependencies.each do |dep|
494
- name = dep.name
495
- platforms = dep.gem_platforms(@platforms)
496
-
497
- packages[name] = Resolver::Package.new(name, platforms, @originally_locked_specs, @unlock[:gems], :dependency => dep)
498
- end
499
-
500
- packages
495
+ last_resolve = converge_locked_specs
496
+ remove_ruby_from_platforms_if_necessary!(current_dependencies)
497
+ packages = Resolver::Base.new(source_requirements, expanded_dependencies, last_resolve, @platforms, :locked_specs => @originally_locked_specs, :unlock => @unlock[:gems], :prerelease => gem_version_promoter.pre?)
498
+ additional_base_requirements_for_resolve(packages, last_resolve)
501
499
  end
502
500
  end
503
501
 
@@ -531,13 +529,15 @@ module Bundler
531
529
  break if incomplete_specs.empty?
532
530
 
533
531
  Bundler.ui.debug("The lockfile does not have all gems needed for the current platform though, Bundler will still re-resolve dependencies")
534
- @resolve = start_resolution(:exclude_specs => incomplete_specs)
532
+ setup_sources_for_resolve
533
+ resolution_packages.delete(incomplete_specs)
534
+ @resolve = start_resolution
535
535
  specs = resolve.materialize(dependencies)
536
536
 
537
537
  still_incomplete_specs = specs.incomplete_specs
538
538
 
539
539
  if still_incomplete_specs == incomplete_specs
540
- package = resolution_packages[incomplete_specs.first.name]
540
+ package = resolution_packages.get_package(incomplete_specs.first.name)
541
541
  resolver.raise_not_found! package
542
542
  end
543
543
 
@@ -550,8 +550,8 @@ module Bundler
550
550
  specs
551
551
  end
552
552
 
553
- def start_resolution(exclude_specs: [])
554
- result = resolver.start(expanded_dependencies, resolution_packages, :exclude_specs => exclude_specs)
553
+ def start_resolution
554
+ result = resolver.start(expanded_dependencies)
555
555
 
556
556
  SpecSet.new(SpecSet.new(result).for(dependencies, false, @platforms))
557
557
  end
@@ -885,11 +885,12 @@ module Bundler
885
885
  current == proposed
886
886
  end
887
887
 
888
- def additional_base_requirements_for_resolve(last_resolve)
889
- return [] unless @locked_gems && unlocking? && !sources.expired_sources?(@locked_gems.sources)
890
- converge_specs(@originally_locked_specs - last_resolve).map do |locked_spec|
891
- Dependency.new(locked_spec.name, ">= #{locked_spec.version}")
892
- end.uniq
888
+ def additional_base_requirements_for_resolve(resolution_packages, last_resolve)
889
+ return resolution_packages unless @locked_gems && unlocking? && !sources.expired_sources?(@locked_gems.sources)
890
+ converge_specs(@originally_locked_specs - last_resolve).each do |locked_spec|
891
+ resolution_packages.base_requirements[locked_spec.name] = Gem::Requirement.new(">= #{locked_spec.version}")
892
+ end
893
+ resolution_packages
893
894
  end
894
895
 
895
896
  def remove_ruby_from_platforms_if_necessary!(dependencies)
@@ -249,17 +249,13 @@ module Bundler
249
249
 
250
250
  # returns whether or not a re-resolve was needed
251
251
  def resolve_if_needed(options)
252
+ @definition.resolution_mode = options
253
+
252
254
  if !@definition.unlocking? && !options["force"] && !Bundler.settings[:inline] && Bundler.default_lockfile.file?
253
255
  return false if @definition.nothing_changed? && !@definition.missing_specs?
254
256
  end
255
257
 
256
- if options["local"]
257
- @definition.resolve_with_cache!
258
- elsif options["prefer-local"]
259
- @definition.resolve_prefering_local!
260
- else
261
- @definition.resolve_remotely!
262
- end
258
+ @definition.setup_sources_for_resolve
263
259
 
264
260
  true
265
261
  end
@@ -89,7 +89,7 @@ module Bundler
89
89
 
90
90
  installable_candidates = GemHelpers.select_best_platform_match(matching_specs, target_platform)
91
91
 
92
- specification = __materialize__(installable_candidates)
92
+ specification = __materialize__(installable_candidates, :fallback_to_non_installable => false)
93
93
  return specification unless specification.nil?
94
94
 
95
95
  if target_platform != platform
@@ -102,13 +102,18 @@ module Bundler
102
102
  __materialize__(candidates)
103
103
  end
104
104
 
105
- def __materialize__(candidates)
105
+ # If in frozen mode, we fallback to a non-installable candidate because by
106
+ # doing this we avoid re-resolving and potentially end up changing the
107
+ # lock file, which is not allowed. In that case, we will give a proper error
108
+ # about the mismatch higher up the stack, right before trying to install the
109
+ # bad gem.
110
+ def __materialize__(candidates, fallback_to_non_installable: Bundler.frozen_bundle?)
106
111
  search = candidates.reverse.find do |spec|
107
112
  spec.is_a?(StubSpecification) ||
108
113
  (spec.matches_current_ruby? &&
109
114
  spec.matches_current_rubygems?)
110
115
  end
111
- if search.nil? && Bundler.frozen_bundle?
116
+ if search.nil? && fallback_to_non_installable
112
117
  search = candidates.last
113
118
  else
114
119
  search.dependencies = dependencies if search && search.full_name == full_name && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification))
@@ -1,19 +1,40 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "package"
4
+
3
5
  module Bundler
4
6
  class Resolver
5
7
  class Base
6
- def initialize(base, additional_base_requirements)
8
+ attr_reader :packages, :source_requirements
9
+
10
+ def initialize(source_requirements, dependencies, base, platforms, options)
11
+ @source_requirements = source_requirements
12
+
7
13
  @base = base
8
- @additional_base_requirements = additional_base_requirements
14
+
15
+ @packages = Hash.new do |hash, name|
16
+ hash[name] = Package.new(name, platforms, **options)
17
+ end
18
+
19
+ dependencies.each do |dep|
20
+ name = dep.name
21
+
22
+ @packages[name] = Package.new(name, dep.gem_platforms(platforms), **options.merge(:dependency => dep))
23
+ end
9
24
  end
10
25
 
11
26
  def [](name)
12
27
  @base[name]
13
28
  end
14
29
 
15
- def delete(spec)
16
- @base.delete(spec)
30
+ def delete(specs)
31
+ specs.each do |spec|
32
+ @base.delete(spec)
33
+ end
34
+ end
35
+
36
+ def get_package(name)
37
+ @packages[name]
17
38
  end
18
39
 
19
40
  def base_requirements
@@ -24,10 +45,14 @@ module Bundler
24
45
  names.each do |name|
25
46
  @base.delete_by_name(name)
26
47
 
27
- @additional_base_requirements.reject! {|dep| dep.name == name }
48
+ @base_requirements.delete(name)
28
49
  end
50
+ end
29
51
 
30
- @base_requirements = nil
52
+ def include_prereleases(names)
53
+ names.each do |name|
54
+ get_package(name).consider_prereleases!
55
+ end
31
56
  end
32
57
 
33
58
  private
@@ -38,7 +63,6 @@ module Bundler
38
63
  req = Gem::Requirement.new(ls.version)
39
64
  base_requirements[ls.name] = req
40
65
  end
41
- @additional_base_requirements.each {|d| base_requirements[d.name] = d.requirement }
42
66
  base_requirements
43
67
  end
44
68
  end
@@ -26,9 +26,8 @@ module Bundler
26
26
 
27
27
  def initialize(version, specs: [])
28
28
  @spec_group = Resolver::SpecGroup.new(specs)
29
- @platforms = specs.map(&:platform).sort_by(&:to_s).uniq
30
29
  @version = Gem::Version.new(version)
31
- @ruby_only = @platforms == [Gem::Platform::RUBY]
30
+ @ruby_only = specs.map(&:platform).uniq == [Gem::Platform::RUBY]
32
31
  end
33
32
 
34
33
  def dependencies
@@ -88,9 +87,7 @@ module Bundler
88
87
  end
89
88
 
90
89
  def to_s
91
- return @version.to_s if @platforms.empty? || @ruby_only
92
-
93
- "#{@version} (#{@platforms.join(", ")})"
90
+ @version.to_s
94
91
  end
95
92
  end
96
93
  end
@@ -15,12 +15,13 @@ module Bundler
15
15
  class Package
16
16
  attr_reader :name, :platforms, :dependency, :locked_version
17
17
 
18
- def initialize(name, platforms, locked_specs, unlock, dependency: nil)
18
+ def initialize(name, platforms, locked_specs:, unlock:, prerelease: false, dependency: nil)
19
19
  @name = name
20
20
  @platforms = platforms
21
21
  @locked_version = locked_specs[name].first&.version
22
22
  @unlock = unlock
23
23
  @dependency = dependency || Dependency.new(name, @locked_version)
24
+ @prerelease = @dependency.prerelease? || @locked_version&.prerelease? || prerelease ? :consider_first : :ignore
24
25
  end
25
26
 
26
27
  def to_s
@@ -47,8 +48,16 @@ module Bundler
47
48
  @unlock.empty? || @unlock.include?(name)
48
49
  end
49
50
 
51
+ def ignores_prereleases?
52
+ @prerelease == :ignore
53
+ end
54
+
50
55
  def prerelease_specified?
51
- @dependency.prerelease?
56
+ @prerelease == :consider_first
57
+ end
58
+
59
+ def consider_prereleases!
60
+ @prerelease = :consider_last
52
61
  end
53
62
 
54
63
  def force_ruby_platform?
@@ -9,26 +9,21 @@ module Bundler
9
9
  class Resolver
10
10
  require_relative "vendored_pub_grub"
11
11
  require_relative "resolver/base"
12
- require_relative "resolver/package"
13
12
  require_relative "resolver/candidate"
14
13
  require_relative "resolver/incompatibility"
15
14
  require_relative "resolver/root"
16
15
 
17
16
  include GemHelpers
18
17
 
19
- def initialize(source_requirements, base, gem_version_promoter, additional_base_requirements)
20
- @source_requirements = source_requirements
21
- @base = Resolver::Base.new(base, additional_base_requirements)
18
+ def initialize(base, gem_version_promoter)
19
+ @source_requirements = base.source_requirements
20
+ @base = base
22
21
  @gem_version_promoter = gem_version_promoter
23
22
  end
24
23
 
25
- def start(requirements, packages, exclude_specs: [])
26
- exclude_specs.each do |spec|
27
- remove_from_candidates(spec)
28
- end
29
-
24
+ def start(requirements)
30
25
  @requirements = requirements
31
- @packages = packages
26
+ @packages = @base.packages
32
27
 
33
28
  root, logger = setup_solver
34
29
 
@@ -78,33 +73,26 @@ module Bundler
78
73
  rescue PubGrub::SolveFailure => e
79
74
  incompatibility = e.incompatibility
80
75
 
81
- names_to_unlock = []
82
- extended_explanation = nil
76
+ names_to_unlock, names_to_allow_prereleases_for, extended_explanation = find_names_to_relax(incompatibility)
83
77
 
84
- while incompatibility.conflict?
85
- cause = incompatibility.cause
86
- incompatibility = cause.incompatibility
87
-
88
- incompatibility.terms.each do |term|
89
- name = term.package.name
90
- names_to_unlock << name if base_requirements[name]
78
+ names_to_relax = names_to_unlock + names_to_allow_prereleases_for
91
79
 
92
- no_versions_incompat = [cause.incompatibility, cause.satisfier].find {|incompat| incompat.cause.is_a?(PubGrub::Incompatibility::NoVersions) }
93
- next unless no_versions_incompat
80
+ if names_to_relax.any?
81
+ if names_to_unlock.any?
82
+ Bundler.ui.debug "Found conflicts with locked dependencies. Will retry with #{names_to_unlock.join(", ")} unlocked...", true
94
83
 
95
- extended_explanation = no_versions_incompat.extended_explanation
84
+ @base.unlock_names(names_to_unlock)
96
85
  end
97
- end
98
-
99
- names_to_unlock.uniq!
100
86
 
101
- if names_to_unlock.any?
102
- Bundler.ui.debug "Found conflicts with locked dependencies. Retrying with #{names_to_unlock.join(", ")} unlocked...", true
87
+ if names_to_allow_prereleases_for.any?
88
+ Bundler.ui.debug "Found conflicts with dependencies with prereleases. Will retrying considering prereleases for #{names_to_allow_prereleases_for.join(", ")}...", true
103
89
 
104
- @base.unlock_names(names_to_unlock)
90
+ @base.include_prereleases(names_to_allow_prereleases_for)
91
+ end
105
92
 
106
93
  root, logger = setup_solver
107
94
 
95
+ Bundler.ui.debug "Retrying resolution...", true
108
96
  retry
109
97
  end
110
98
 
@@ -118,6 +106,35 @@ module Bundler
118
106
  raise SolveFailure.new(explanation)
119
107
  end
120
108
 
109
+ def find_names_to_relax(incompatibility)
110
+ names_to_unlock = []
111
+ names_to_allow_prereleases_for = []
112
+ extended_explanation = nil
113
+
114
+ while incompatibility.conflict?
115
+ cause = incompatibility.cause
116
+ incompatibility = cause.incompatibility
117
+
118
+ incompatibility.terms.each do |term|
119
+ package = term.package
120
+ name = package.name
121
+
122
+ if base_requirements[name]
123
+ names_to_unlock << name
124
+ elsif package.ignores_prereleases?
125
+ names_to_allow_prereleases_for << name
126
+ end
127
+
128
+ no_versions_incompat = [cause.incompatibility, cause.satisfier].find {|incompat| incompat.cause.is_a?(PubGrub::Incompatibility::NoVersions) }
129
+ next unless no_versions_incompat
130
+
131
+ extended_explanation = no_versions_incompat.extended_explanation
132
+ end
133
+ end
134
+
135
+ [names_to_unlock.uniq, names_to_allow_prereleases_for.uniq, extended_explanation]
136
+ end
137
+
121
138
  def parse_dependency(package, dependency)
122
139
  range = if repository_for(package).is_a?(Source::Gemspec)
123
140
  PubGrub::VersionRange.any
@@ -215,7 +232,7 @@ module Bundler
215
232
 
216
233
  def all_versions_for(package)
217
234
  name = package.name
218
- results = (@base[name] + @all_specs[name]).uniq(&:full_name)
235
+ results = (@base[name] + filter_prereleases(@all_specs[name], package)).uniq {|spec| [spec.version.hash, spec.platform] }
219
236
  locked_requirement = base_requirements[name]
220
237
  results = filter_matching_specs(results, locked_requirement) if locked_requirement
221
238
 
@@ -284,6 +301,12 @@ module Bundler
284
301
  end
285
302
  end
286
303
 
304
+ def filter_prereleases(specs, package)
305
+ return specs unless package.ignores_prereleases?
306
+
307
+ specs.reject {|s| s.version.prerelease? }
308
+ end
309
+
287
310
  def requirement_satisfied_by?(requirement, spec)
288
311
  requirement.satisfied_by?(spec.version) || spec.source.is_a?(Source::Gemspec)
289
312
  end
@@ -304,10 +327,6 @@ module Bundler
304
327
  @base.base_requirements
305
328
  end
306
329
 
307
- def remove_from_candidates(spec)
308
- @base.delete(spec)
309
- end
310
-
311
330
  def prepare_dependencies(requirements, packages)
312
331
  to_dependency_hash(requirements, packages).map do |dep_package, dep_constraint|
313
332
  name = dep_package.name
@@ -322,7 +341,15 @@ module Bundler
322
341
  end
323
342
 
324
343
  next [dep_package, dep_constraint] if name == "bundler"
325
- next [dep_package, dep_constraint] unless versions_for(dep_package, dep_constraint.range).empty?
344
+
345
+ versions = versions_for(dep_package, dep_constraint.range)
346
+ if versions.empty? && dep_package.ignores_prereleases?
347
+ @sorted_versions.delete(dep_package)
348
+ dep_package.consider_prereleases!
349
+ versions = versions_for(dep_package, dep_constraint.range)
350
+ end
351
+ next [dep_package, dep_constraint] unless versions.empty?
352
+
326
353
  next unless dep_package.current_platform?
327
354
 
328
355
  raise_not_found!(dep_package)
@@ -284,7 +284,7 @@ module Bundler
284
284
  Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file
285
285
  Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", find_gemfile.to_s
286
286
  Bundler::SharedHelpers.set_env "BUNDLER_VERSION", Bundler::VERSION
287
- Bundler::SharedHelpers.set_env "BUNDLER_SETUP", File.expand_path("setup", __dir__)
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
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module Bundler
4
- VERSION = "2.4.3".freeze
4
+ VERSION = "2.4.4".freeze
5
5
 
6
6
  def self.bundler_major_version
7
7
  @bundler_major_version ||= VERSION.split(".").first.to_i
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.3
4
+ version: 2.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - André Arko
@@ -22,7 +22,7 @@ authors:
22
22
  autorequire:
23
23
  bindir: exe
24
24
  cert_chain: []
25
- date: 2023-01-06 00:00:00.000000000 Z
25
+ date: 2023-01-16 00:00:00.000000000 Z
26
26
  dependencies: []
27
27
  description: Bundler manages an application's dependencies through its entire life,
28
28
  across many machines, systematically and repeatably
@@ -380,7 +380,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
380
380
  - !ruby/object:Gem::Version
381
381
  version: 3.0.1
382
382
  requirements: []
383
- rubygems_version: 3.4.3
383
+ rubygems_version: 3.4.4
384
384
  signing_key:
385
385
  specification_version: 4
386
386
  summary: The best way to manage your application's dependencies