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

ruby-changes:70277

From: David <ko1@a...>
Date: Fri, 17 Dec 2021 16:35:41 +0900 (JST)
Subject: [ruby-changes:70277] 8d29d1292b (master): [rubygems/rubygems] Improve errors a bit more

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

From 8d29d1292b35ad524ce15f82177a2975da43432d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Wed, 15 Dec 2021 13:28:50 +0100
Subject: [rubygems/rubygems] Improve errors a bit more

https://github.com/rubygems/rubygems/commit/f481e8f41a
---
 lib/bundler/resolver.rb                                |  7 ++++++-
 spec/bundler/commands/exec_spec.rb                     |  9 +++++++--
 spec/bundler/install/gemfile/git_spec.rb               |  6 +++---
 spec/bundler/install/gemfile/specific_platform_spec.rb | 18 ++++++++++++++----
 4 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index 37c27f213d0..22d61fba367 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -287,7 +287,12 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/resolver.rb#L287
       end
 
       message = String.new("Could not find gem '#{requirement_label}'#{extra_message} in #{source}#{cache_message}.\n")
-      message << "The source contains the following gems matching '#{matching_part}': #{specs.map(&:full_name).join(", ")}" if specs.any?
+
+      if specs.any?
+        message << "\nThe source contains the following gems matching '#{matching_part}':\n"
+        message << specs.map {|s| "  * #{s.full_name}" }.join("\n")
+      end
+
       message
     end
 
diff --git a/spec/bundler/commands/exec_spec.rb b/spec/bundler/commands/exec_spec.rb
index 83e80883495..f2b7863591f 100644
--- a/spec/bundler/commands/exec_spec.rb
+++ b/spec/bundler/commands/exec_spec.rb
@@ -867,7 +867,10 @@ 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 gems matching 'rack': rack-0.9.1, rack-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 +897,9 @@ Run `bundle install` to install missing gems. https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/exec_spec.rb#L897
       let(:expected) { "" }
       let(:expected_err) { <<-EOS.strip }
 Could not find gem 'rack (= 2)' in locally installed gems.
-The source contains the following gems matching 'rack': 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 cffb7308413..a0fb4a3cea2 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 gems matching 'foo': foo-1.0")
+      expect(err).to include("The source contains the following gems matching 'foo':\n  * 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 gems matching 'only_java': only_java-1.0-java")
+      expect(err).to include("The source contains the following gems matching 'only_java':\n  * 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 gems matching 'only_java': only_java-1.0-java, only_java-1.1-java")
+      expect(err).to include("The source contains the following gems matching 'only_java':\n  * only_java-1.0-java\n  * only_java-1.1-java")
     end
 
     it "still works after moving the application directory" do
diff --git a/spec/bundler/install/gemfile/specific_platform_spec.rb b/spec/bundler/install/gemfile/specific_platform_spec.rb
index 6035f55ef27..113a0a1352c 100644
--- a/spec/bundler/install/gemfile/specific_platform_spec.rb
+++ b/spec/bundler/install/gemfile/specific_platform_spec.rb
@@ -298,8 +298,13 @@ RSpec.describe "bundle install with specific platforms" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/install/gemfile/specific_platform_spec.rb#L298
       bundle "install", :raise_on_error => false
     end
 
-    expect(err).to include("Could not find gem 'sorbet-static (= 0.5.6433) arm64-darwin-21' in rubygems repository #{file_uri_for(gem_repo2)}/ or installed locally.")
-    expect(err).to include("The source contains the following gems matching 'sorbet-static (= 0.5.6433)': sorbet-static-0.5.6433-universal-darwin-20, sorbet-static-0.5.6433-x86_64-linux")
+    expect(err).to include <<~ERROR.rstrip
+      Could not find gem 'sorbet-static (= 0.5.6433) arm64-darwin-21' in rubygems repository #{file_uri_for(gem_repo2)}/ or installed locally.
+
+      The source contains the following gems matching 'sorbet-static (= 0.5.6433)':
+        * sorbet-static-0.5.6433-universal-darwin-20
+        * sorbet-static-0.5.6433-x86_64-linux
+    ERROR
   end
 
   it "does not resolve if the current platform does not match any of available platform specific variants for a transitive dependency" do
@@ -319,8 +324,13 @@ RSpec.describe "bundle install with specific platforms" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/install/gemfile/specific_platform_spec.rb#L324
       bundle "install", :raise_on_error => false
     end
 
-    expect(err).to include("Could not find gem 'sorbet-static (= 0.5.6433) arm64-darwin-21', which is required by gem 'sorbet (= 0.5.6433)', in rubygems repository #{file_uri_for(gem_repo2)}/ or installed locally.")
-    expect(err).to include("The source contains the following gems matching 'sorbet-static (= 0.5.6433)': sorbet-static-0.5.6433-universal-darwin-20, sorbet-static-0.5.6433-x86_64-linux")
+    expect(err).to include <<~ERROR.rstrip
+      Could not find gem 'sorbet-static (= 0.5.6433) arm64-darwin-21', which is required by gem 'sorbet (= 0.5.6433)', in rubygems repository #{file_uri_for(gem_repo2)}/ or installed locally.
+
+      The source contains the following gems matching 'sorbet-static (= 0.5.6433)':
+        * sorbet-static-0.5.6433-universal-darwin-20
+        * sorbet-static-0.5.6433-x86_64-linux
+    ERROR
   end
 
   private
-- 
cgit v1.2.1


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

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