[前][次][番号順一覧][スレッド一覧]

ruby-changes:71792

From: David <ko1@a...>
Date: Wed, 11 May 2022 16:56:06 +0900 (JST)
Subject: [ruby-changes:71792] 8f1a8e68ba (master): [rubygems/rubygems] Fix error message on metadata mismatches

https://git.ruby-lang.org/ruby.git/commit/?id=8f1a8e68ba

From 8f1a8e68bae29bed1052d6b518e1fb4a01e53cbd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Wed, 6 Apr 2022 09:22:49 +0200
Subject: [rubygems/rubygems] Fix error message on metadata mismatches

Previously we were removing not installable specs. However, if those are
the only ones, that would result in a bad error message. If we still
choose them as a last resort, Bundler will later check metadata right
before installing a give a proper error.

This is a regression of https://github.com/rubygems/rubygems/commit/565549260be5 and the
fix is to revert that commit.

https://github.com/rubygems/rubygems/commit/bc18912257
---
 lib/bundler/lazy_specification.rb           |  2 +-
 spec/bundler/install/gems/resolving_spec.rb | 37 +++++++++++++++++++++++++++++
 spec/bundler/support/helpers.rb             |  4 ++++
 3 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb
index fd7c8defdc..198906b987 100644
--- a/lib/bundler/lazy_specification.rb
+++ b/lib/bundler/lazy_specification.rb
@@ -94,7 +94,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/lazy_specification.rb#L94
             (spec.required_ruby_version.satisfied_by?(Gem.ruby_version) &&
               spec.required_rubygems_version.satisfied_by?(Gem.rubygems_version))
         end
-        search = installable_candidates.last
+        search = installable_candidates.last || same_platform_candidates.last
         search.dependencies = dependencies if search && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification))
         search
       end
diff --git a/spec/bundler/install/gems/resolving_spec.rb b/spec/bundler/install/gems/resolving_spec.rb
index 83f1e60806..469ecd412f 100644
--- a/spec/bundler/install/gems/resolving_spec.rb
+++ b/spec/bundler/install/gems/resolving_spec.rb
@@ -245,6 +245,43 @@ RSpec.describe "bundle install with install-time dependencies" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/install/gems/resolving_spec.rb#L245
         expect(the_bundle).to include_gems("rack 1.2")
       end
 
+      it "gives a meaningful error if there's a lockfile using the newer incompatible version" do
+        build_repo2 do
+          build_gem "parallel_tests", "3.7.0" do |s|
+            s.required_ruby_version = ">= #{current_ruby_minor}"
+          end
+
+          build_gem "parallel_tests", "3.8.0" do |s|
+            s.required_ruby_version = ">= #{next_ruby_minor}"
+          end
+        end
+
+        gemfile <<-G
+          source "http://localgemserver.test/"
+          gem 'parallel_tests'
+        G
+
+        lockfile <<~L
+          GEM
+            remote: http://localgemserver.test/
+            specs:
+              parallel_tests (3.8.0)
+
+          PLATFORMS
+            #{lockfile_platforms}
+
+          DEPENDENCIES
+            parallel_tests
+
+          BUNDLED WITH
+             #{Bundler::VERSION}
+        L
+
+        bundle "install --verbose", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo2.to_s }, :raise_on_error => false
+        expect(err).to include("parallel_tests-3.8.0 requires ruby version >= #{next_ruby_minor}")
+        expect(err).not_to include("That means the author of parallel_tests (3.8.0) has removed it.")
+      end
+
       it "installs the older version under rate limiting conditions" do
         build_repo4 do
           build_gem "rack", "9001.0.0" do |s|
diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb
index ab6a0625bb..e995418a4e 100644
--- a/spec/bundler/support/helpers.rb
+++ b/spec/bundler/support/helpers.rb
@@ -471,6 +471,10 @@ module Spec https://github.com/ruby/ruby/blob/trunk/spec/bundler/support/helpers.rb#L471
       end
     end
 
+    def current_ruby_minor
+      Gem.ruby_version.segments[0..1].join(".")
+    end
+
     def next_ruby_minor
       Gem.ruby_version.segments[0..1].map.with_index {|s, i| i == 1 ? s + 1 : s }.join(".")
     end
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]