diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2022-12-17 01:20:14 +0100 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2022-12-20 13:15:02 +0900 |
commit | 1db9bcfeaf27b8a8ced1ea5ad13f5c5774530a6b (patch) | |
tree | ff3f0e13f0e6ea1716bbff653e1300bc14968fb1 /lib/bundler/resolver.rb | |
parent | 829348956476fc395f267b3f4a20ea67546551b2 (diff) |
[rubygems/rubygems] Fix crash when building resolution errors with OR requirements
https://github.com/rubygems/rubygems/commit/8f287479bc
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/6966
Diffstat (limited to 'lib/bundler/resolver.rb')
-rw-r--r-- | lib/bundler/resolver.rb | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index 82cf66cc6d..b654cb819d 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -118,13 +118,13 @@ module Bundler name = package.name constraint = unsatisfied_term.constraint constraint_string = constraint.constraint_string - requirement = Gem::Requirement.new(constraint_string.split(",")) + requirements = constraint_string.split(" OR ").map {|req| Gem::Requirement.new(req.split(",")) } if name == "bundler" custom_explanation = "the current Bundler version (#{Bundler::VERSION}) does not satisfy #{constraint}" - extended_explanation = bundler_not_found_message(requirement) + extended_explanation = bundler_not_found_message(requirements) else - specs_matching_other_platforms = filter_matching_specs(@all_specs[name], requirement) + specs_matching_other_platforms = filter_matching_specs(@all_specs[name], requirements) platforms_explanation = specs_matching_other_platforms.any? ? " for any resolution platforms (#{package.platforms.join(", ")})" : "" custom_explanation = "#{constraint} could not be found in #{repository_for(package)}#{platforms_explanation}" @@ -265,8 +265,10 @@ module Bundler private - def filter_matching_specs(specs, requirement) - specs.select {| spec| requirement_satisfied_by?(requirement, spec) } + def filter_matching_specs(specs, requirements) + Array(requirements).flat_map do |requirement| + specs.select {| spec| requirement_satisfied_by?(requirement, spec) } + end end def requirement_satisfied_by?(requirement, spec) @@ -357,8 +359,9 @@ module Bundler end end - def bundler_not_found_message(conflict_dependency) - candidate_specs = filter_matching_specs(source_for(:default_bundler).specs.search("bundler"), conflict_dependency) + def bundler_not_found_message(conflict_dependencies) + candidate_specs = filter_matching_specs(source_for(:default_bundler).specs.search("bundler"), conflict_dependencies) + if candidate_specs.any? target_version = candidate_specs.last.version new_command = [File.basename($PROGRAM_NAME), "_#{target_version}_", *ARGV].join(" ") |