From 9d834e68c553578006b2ff414ffc96514b9aa2f5 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Mon, 15 Oct 2018 07:55:42 +0900 Subject: Remove the duplicate gems from suggestions If the lock file has the same gems for different platforms, the suggestion includes all those gems. For example, using the Rails's lock file(https://github.com/rails/rails/blob/4a51cbba58435bbba65ca50670bd6ae4887942bd/Gemfile.lock), it shows like this: ``` $ bundle update mai Could not find gem 'mai'. Did you mean ffi, ffi, ffi, ffi, mail, ast, jwt, que or wdm? ``` Since it is unnecessary to include the same gem, removed duplicate gems. --- lib/bundler/cli/common.rb | 2 +- spec/commands/update_spec.rb | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/bundler/cli/common.rb b/lib/bundler/cli/common.rb index 8084405b38..09a1753337 100644 --- a/lib/bundler/cli/common.rb +++ b/lib/bundler/cli/common.rb @@ -72,7 +72,7 @@ module Bundler end def self.ensure_all_gems_in_lockfile!(names, locked_gems = Bundler.locked_gems) - locked_names = locked_gems.specs.map(&:name) + locked_names = locked_gems.specs.map(&:name).uniq names.-(locked_names).each do |g| raise GemNotFound, gem_not_found_message(g, locked_names) end diff --git a/spec/commands/update_spec.rb b/spec/commands/update_spec.rb index 6eb49d3acd..6f29032dd2 100644 --- a/spec/commands/update_spec.rb +++ b/spec/commands/update_spec.rb @@ -8,6 +8,7 @@ RSpec.describe "bundle update" do source "file://#{gem_repo2}" gem "activesupport" gem "rack-obama" + gem "platform_specific" G end @@ -116,8 +117,8 @@ RSpec.describe "bundle update" do expect(out).to include "Could not find gem 'halting-problem-solver'" end it "should suggest alternatives" do - bundle "update active-support" - expect(out).to include "Did you mean activesupport?" + bundle "update platformspecific" + expect(out).to include "Did you mean platform_specific?" end end -- cgit v1.2.1