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

ruby-changes:70276

From: David <ko1@a...>
Date: Fri, 17 Dec 2021 16:35:40 +0900 (JST)
Subject: [ruby-changes:70276] af4b4fd19b (master): [rubygems/rubygems] Improve resolver error messages

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

From af4b4fd19b7972adc165e70e9d41ad7e14c9a235 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Tue, 14 Dec 2021 14:49:43 +0100
Subject: [rubygems/rubygems] Improve resolver error messages

Use a more standard naming for gems.

https://github.com/rubygems/rubygems/commit/75121e83f1
---
 lib/bundler/resolver.rb                  | 14 +-------------
 spec/bundler/commands/exec_spec.rb       |  4 ++--
 spec/bundler/install/gemfile/git_spec.rb |  6 +++---
 3 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index 5eb17a3921a..8830621e0ef 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -264,30 +264,18 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/resolver.rb#L264
         else
           source = source_for(name)
           specs = source.specs.search(name)
-          versions_with_platforms = specs.map {|s| [s.version, s.platform] }
           cache_message = begin
                               " or in gems cached in #{Bundler.settings.app_cache_path}" if Bundler.app_cache.exist?
                             rescue GemfileNotFound
                               nil
                             end
           message = String.new("Could not find gem '#{SharedHelpers.pretty_dependency(requirement)}' in #{source}#{cache_message}.\n")
-          message << "The source contains the following versions of '#{name}': #{formatted_versions_with_platforms(versions_with_platforms)}" if versions_with_platforms.any?
+          message << "The source contains the following gems matching '#{name}': #{specs.map(&:full_name).join(", ")}" if specs.any?
         end
         raise GemNotFound, message
       end
     end
 
-    def formatted_versions_with_platforms(versions_with_platforms)
-      version_platform_strs = versions_with_platforms.map do |vwp|
-        version = vwp.first
-        platform = vwp.last
-        version_platform_str = String.new(version.to_s)
-        version_platform_str << " #{platform}" unless platform.nil? || platform == Gem::Platform::RUBY
-        version_platform_str
-      end
-      version_platform_strs.join(", ")
-    end
-
     def version_conflict_message(e)
       # only show essential conflicts, if possible
       conflicts = e.conflicts.dup
diff --git a/spec/bundler/commands/exec_spec.rb b/spec/bundler/commands/exec_spec.rb
index e67e5b96ef2..83e80883495 100644
--- a/spec/bundler/commands/exec_spec.rb
+++ b/spec/bundler/commands/exec_spec.rb
@@ -867,7 +867,7 @@ RSpec.describe "bundle exec" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/exec_spec.rb#L867
       let(:expected) { "" }
       let(:expected_err) { <<-EOS.strip }
 Could not find gem 'rack (= 2)' in locally installed gems.
-The source contains the following versions of 'rack': 0.9.1, 1.0.0
+The source contains the following gems matching 'rack': rack-0.9.1, rack-1.0.0
 Run `bundle install` to install missing gems.
       EOS
 
@@ -894,7 +894,7 @@ Run `bundle install` to install missing gems. https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/exec_spec.rb#L894
       let(:expected) { "" }
       let(:expected_err) { <<-EOS.strip }
 Could not find gem 'rack (= 2)' in locally installed gems.
-The source contains the following versions of 'rack': 1.0.0
+The source contains the following gems matching 'rack': rack-1.0.0
 Run `bundle install` to install missing gems.
       EOS
 
diff --git a/spec/bundler/install/gemfile/git_spec.rb b/spec/bundler/install/gemfile/git_spec.rb
index 150fcf2c420..cffb7308413 100644
--- a/spec/bundler/install/gemfile/git_spec.rb
+++ b/spec/bundler/install/gemfile/git_spec.rb
@@ -89,7 +89,7 @@ RSpec.describe "bundle install with git sources" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/install/gemfile/git_spec.rb#L89
         gem "foo", "1.1", :git => "#{lib_path("foo-1.0")}"
       G
 
-      expect(err).to include("The source contains the following versions of 'foo': 1.0")
+      expect(err).to include("The source contains the following gems matching 'foo': foo-1.0")
     end
 
     it "complains with version and platform if pinned specs don't exist in the git repo" do
@@ -106,7 +106,7 @@ RSpec.describe "bundle install with git sources" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/install/gemfile/git_spec.rb#L106
         end
       G
 
-      expect(err).to include("The source contains the following versions of 'only_java': 1.0 java")
+      expect(err).to include("The source contains the following gems matching 'only_java': only_java-1.0-java")
     end
 
     it "complains with multiple versions and platforms if pinned specs don't exist in the git repo" do
@@ -128,7 +128,7 @@ RSpec.describe "bundle install with git sources" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/install/gemfile/git_spec.rb#L128
         end
       G
 
-      expect(err).to include("The source contains the following versions of 'only_java': 1.0 java, 1.1 java")
+      expect(err).to include("The source contains the following gems matching 'only_java': only_java-1.0-java, only_java-1.1-java")
     end
 
     it "still works after moving the application directory" do
-- 
cgit v1.2.1


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

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