ruby-changes:71858
From: Hiroshi <ko1@a...>
Date: Wed, 18 May 2022 10:03:10 +0900 (JST)
Subject: [ruby-changes:71858] 2e291e3ffd (ruby_3_1): Merge RubyGems-3.3.12 and Bundler-2.3.12
https://git.ruby-lang.org/ruby.git/commit/?id=2e291e3ffd From 2e291e3ffdea1cba747119ff58cf253f4c4a87c8 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA <hsbt@r...> Date: Mon, 2 May 2022 19:42:57 +0900 Subject: Merge RubyGems-3.3.12 and Bundler-2.3.12 --- lib/bundler/current_ruby.rb | 1 + lib/bundler/definition.rb | 19 +- lib/bundler/dependency.rb | 18 + lib/bundler/resolver.rb | 87 ++- lib/bundler/resolver/spec_group.rb | 4 +- lib/bundler/ruby_version.rb | 13 - lib/bundler/rubygems_ext.rb | 17 + lib/bundler/source/metadata.rb | 2 +- .../molinillo/lib/molinillo/dependency_graph.rb | 2 +- .../vendor/molinillo/lib/molinillo/errors.rb | 58 +- .../vendor/molinillo/lib/molinillo/gem_metadata.rb | 2 +- lib/bundler/vendor/tsort/lib/tsort.rb | 637 ++++++++++----------- lib/bundler/version.rb | 2 +- lib/rubygems.rb | 14 +- lib/rubygems/installer.rb | 2 - lib/rubygems/optparse/lib/optparse.rb | 77 ++- lib/rubygems/optparse/lib/optparse/ac.rb | 2 +- lib/rubygems/optparse/lib/optparse/date.rb | 2 +- lib/rubygems/optparse/lib/optparse/kwargs.rb | 2 +- lib/rubygems/optparse/lib/optparse/shellwords.rb | 2 +- lib/rubygems/optparse/lib/optparse/time.rb | 2 +- lib/rubygems/optparse/lib/optparse/uri.rb | 2 +- lib/rubygems/specification.rb | 10 + spec/bundler/bundler/dsl_spec.rb | 5 +- spec/bundler/bundler/ruby_version_spec.rb | 26 - spec/bundler/install/gems/resolving_spec.rb | 37 +- test/rubygems/helper.rb | 7 +- test/rubygems/test_gem.rb | 20 +- test/rubygems/test_gem_ext_cargo_builder.rb | 4 +- .../custom_name/Cargo.lock | 4 +- .../rust_ruby_example/Cargo.lock | 4 +- test/rubygems/test_gem_installer.rb | 8 +- tool/bundler/dev_gems.rb.lock | 2 +- tool/bundler/rubocop_gems.rb.lock | 2 +- tool/bundler/standard_gems.rb.lock | 2 +- tool/bundler/test_gems.rb.lock | 2 +- 36 files changed, 602 insertions(+), 498 deletions(-) diff --git a/lib/bundler/current_ruby.rb b/lib/bundler/current_ruby.rb index f84d68e262..27997982c0 100644 --- a/lib/bundler/current_ruby.rb +++ b/lib/bundler/current_ruby.rb @@ -21,6 +21,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/current_ruby.rb#L21 2.6 2.7 3.0 + 3.1 ].freeze KNOWN_MAJOR_VERSIONS = KNOWN_MINOR_VERSIONS.map {|v| v.split(".", 2).first }.uniq.freeze diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 442f4484fb..21949bc85c 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -732,30 +732,13 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L732 def metadata_dependencies @metadata_dependencies ||= begin - ruby_versions = ruby_version_requirements(@ruby_version) [ - Dependency.new("Ruby\0", ruby_versions), + Dependency.new("Ruby\0", RubyVersion.system.gem_version), Dependency.new("RubyGems\0", Gem::VERSION), ] end end - def ruby_version_requirements(ruby_version) - return [] unless ruby_version - if ruby_version.patchlevel - [ruby_version.to_gem_version_with_patchlevel] - else - ruby_version.versions.map do |version| - requirement = Gem::Requirement.new(version) - if requirement.exact? - "~> #{version}.0" - else - requirement - end - end - end - end - def expand_dependencies(dependencies, remote = false) deps = [] dependencies.each do |dep| diff --git a/lib/bundler/dependency.rb b/lib/bundler/dependency.rb index 94e85053dd..d12b120bba 100644 --- a/lib/bundler/dependency.rb +++ b/lib/bundler/dependency.rb @@ -20,6 +20,9 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/dependency.rb#L20 :ruby_24 => Gem::Platform::RUBY, :ruby_25 => Gem::Platform::RUBY, :ruby_26 => Gem::Platform::RUBY, + :ruby_27 => Gem::Platform::RUBY, + :ruby_30 => Gem::Platform::RUBY, + :ruby_31 => Gem::Platform::RUBY, :mri => Gem::Platform::RUBY, :mri_18 => Gem::Platform::RUBY, :mri_19 => Gem::Platform::RUBY, @@ -30,6 +33,9 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/dependency.rb#L33 :mri_24 => Gem::Platform::RUBY, :mri_25 => Gem::Platform::RUBY, :mri_26 => Gem::Platform::RUBY, + :mri_27 => Gem::Platform::RUBY, + :mri_30 => Gem::Platform::RUBY, + :mri_31 => Gem::Platform::RUBY, :rbx => Gem::Platform::RUBY, :truffleruby => Gem::Platform::RUBY, :jruby => Gem::Platform::JAVA, @@ -45,6 +51,9 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/dependency.rb#L51 :mswin_24 => Gem::Platform::MSWIN, :mswin_25 => Gem::Platform::MSWIN, :mswin_26 => Gem::Platform::MSWIN, + :mswin_27 => Gem::Platform::MSWIN, + :mswin_30 => Gem::Platform::MSWIN, + :mswin_31 => Gem::Platform::MSWIN, :mswin64 => Gem::Platform::MSWIN64, :mswin64_19 => Gem::Platform::MSWIN64, :mswin64_20 => Gem::Platform::MSWIN64, @@ -54,6 +63,9 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/dependency.rb#L63 :mswin64_24 => Gem::Platform::MSWIN64, :mswin64_25 => Gem::Platform::MSWIN64, :mswin64_26 => Gem::Platform::MSWIN64, + :mswin64_27 => Gem::Platform::MSWIN64, + :mswin64_30 => Gem::Platform::MSWIN64, + :mswin64_31 => Gem::Platform::MSWIN64, :mingw => Gem::Platform::MINGW, :mingw_18 => Gem::Platform::MINGW, :mingw_19 => Gem::Platform::MINGW, @@ -64,6 +76,9 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/dependency.rb#L76 :mingw_24 => Gem::Platform::MINGW, :mingw_25 => Gem::Platform::MINGW, :mingw_26 => Gem::Platform::MINGW, + :mingw_27 => Gem::Platform::MINGW, + :mingw_30 => Gem::Platform::MINGW, + :mingw_31 => Gem::Platform::MINGW, :x64_mingw => Gem::Platform::X64_MINGW, :x64_mingw_20 => Gem::Platform::X64_MINGW, :x64_mingw_21 => Gem::Platform::X64_MINGW, @@ -72,6 +87,9 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/dependency.rb#L87 :x64_mingw_24 => Gem::Platform::X64_MINGW, :x64_mingw_25 => Gem::Platform::X64_MINGW, :x64_mingw_26 => Gem::Platform::X64_MINGW, + :x64_mingw_27 => Gem::Platform::X64_MINGW, + :x64_mingw_30 => Gem::Platform::X64_MINGW, + :x64_mingw_31 => Gem::Platform::X64_MINGW, }.freeze def initialize(name, version, options = {}, &blk) diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index be0751d9d2..433a5e53e1 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -312,29 +312,66 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/resolver.rb#L312 e = Molinillo::VersionConflict.new(conflicts, e.specification_provider) unless conflicts.empty? - solver_name = "Bundler" - possibility_type = "gem" e.message_with_trees( - :solver_name => solver_name, - :possibility_type => possibility_type, - :reduce_trees => lambda do |trees| + :full_message_for_conflict => lambda do |name, conflict| + o = if name.end_with?("\0") + String.new("Bundler found conflicting requirements for the #{name} version:") + else + String.new("Bundler could not find compatible versions for gem \"#{name}\":") + end + o << %(\n) + if conflict.locked_requirement + o << %( In snapshot (#{name_for_locking_dependency_source}):\n) + o << %( #{SharedHelpers.pretty_dependency(conflict.locked_requirement)}\n) + o << %(\n) + end + o << %( In #{name_for_explicit_dependency_source}:\n) + trees = conflict.requirement_trees + # called first, because we want to reduce the amount of work required to find maximal empty sets trees = trees.uniq {|t| t.flatten.map {|dep| [dep.name, dep.requirement] } } # bail out if tree size is too big for Array#combination to make any sense - return trees if trees.size > 15 - maximal = 1.upto(trees.size).map do |size| - trees.map(&:last).flatten(1).combination(size).to_a - end.flatten(1).select do |deps| - Bundler::VersionRanges.empty?(*Bundler::VersionRanges.for_many(deps.map(&:requirement))) - end.min_by(&:size) - - trees.reject! {|t| !maximal.include?(t.last) } if maximal - - trees.sort_by {|t| t.reverse.map(&:name) } - end, - :printable_requirement => lambda {|req| SharedHelpers.pretty_dependency(req) }, - :additional_message_for_conflict => lambda do |o, name, conflict| + if trees.size <= 15 + maximal = 1.upto(trees.size).map do |size| + trees.map(&:last).flatten(1).combination(size).to_a + end.flatten(1).select do |deps| + Bundler::VersionRanges.empty?(*Bundler::VersionRanges.for_many(deps.map(&:requirement))) + end.min_by(&:size) + + trees.reject! {|t| !maximal.include?(t.last) } if maximal + + trees.sort_by! {|t| t.reverse.map(&:name) } + end + + metadata_requirements = {} + + o << trees.map do |tree| + t = "".dup + (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/