From 01560e1c53ce2e1fcf3cdc2480c6f75ca7c6f0a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Fri, 19 Nov 2021 13:13:19 +0100 Subject: [PATCH] [rubygems/rubygems] Improve error message when gems cannot be found Include the source of each gem. https://github.com/rubygems/rubygems/commit/a0bed2fb79 --- lib/bundler/definition.rb | 6 +++++- spec/bundler/install/yanked_spec.rb | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 0580860845..8f43befe35 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -495,7 +495,11 @@ module Bundler "removed in order to install." end - raise GemNotFound, "Could not find #{missing_specs.map(&:full_name).join(", ")} in any of the sources" + missing_specs_list = missing_specs.group_by(&:source).map do |source, missing_specs_for_source| + "#{missing_specs_for_source.map(&:full_name).join(", ")} in #{source}" + end + + raise GemNotFound, "Could not find #{missing_specs_list.join(" nor ")}" end unless specs["bundler"].any? diff --git a/spec/bundler/install/yanked_spec.rb b/spec/bundler/install/yanked_spec.rb index b53c15be69..3acae85afd 100644 --- a/spec/bundler/install/yanked_spec.rb +++ b/spec/bundler/install/yanked_spec.rb @@ -65,7 +65,7 @@ RSpec.context "when using gem before installing" do bundle :list, :raise_on_error => false - expect(err).to include("Could not find rack-0.9.1 in any of the sources") + expect(err).to include("Could not find rack-0.9.1 in locally installed gems") expect(err).to_not include("Your bundle is locked to rack (0.9.1) from") expect(err).to_not include("If you haven't changed sources, that means the author of rack (0.9.1) has removed it.") expect(err).to_not include("You'll need to update your bundle to a different version of rack (0.9.1) that hasn't been removed in order to install.") @@ -95,7 +95,7 @@ RSpec.context "when using gem before installing" do bundle :list, :raise_on_error => false - expect(err).to include("Could not find rack-0.9.1, rack_middleware-1.0 in any of the sources") + expect(err).to include("Could not find rack-0.9.1, rack_middleware-1.0 in locally installed gems") expect(err).to include("Install missing gems with `bundle install`.") expect(err).to_not include("Your bundle is locked to rack (0.9.1) from") expect(err).to_not include("If you haven't changed sources, that means the author of rack (0.9.1) has removed it.")