From e4823ea6fe4fa7a89c2dd6da59e091e29ba5a6f0 Mon Sep 17 00:00:00 2001 From: Mike Fiedler Date: Sun, 10 May 2020 11:25:49 -0400 Subject: [PATCH 1/2] cmd/uninstall: fix Array comparison In #7526 a comparison for `paths` was introduced, but if `paths` is ever `nil`, this triggers an error. Coercing the variable to an Array should alleviate this problem, as `nil.to_a` produces an empty and comparable Array. Fixes #7540 Signed-off-by: Mike Fiedler --- Library/Homebrew/cmd/uninstall.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/cmd/uninstall.rb b/Library/Homebrew/cmd/uninstall.rb index c5fa22ea17..e679377d40 100644 --- a/Library/Homebrew/cmd/uninstall.rb +++ b/Library/Homebrew/cmd/uninstall.rb @@ -92,7 +92,7 @@ module Homebrew end unversioned_name = f.name.gsub(/@.+$/, "") - maybe_paths = Dir.glob("#{f.etc}/*#{unversioned_name}*") - paths + maybe_paths = Dir.glob("#{f.etc}/*#{unversioned_name}*") - paths.to_a if maybe_paths.present? puts opoo <<~EOS From a3474e8361c01910b9b05d6c2abc7ae25d6da52f Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 10 May 2020 19:22:54 +0100 Subject: [PATCH 2/2] uninstall: tweak paths array logic. --- Library/Homebrew/cmd/uninstall.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cmd/uninstall.rb b/Library/Homebrew/cmd/uninstall.rb index e679377d40..a27c45eaf5 100644 --- a/Library/Homebrew/cmd/uninstall.rb +++ b/Library/Homebrew/cmd/uninstall.rb @@ -92,7 +92,8 @@ module Homebrew end unversioned_name = f.name.gsub(/@.+$/, "") - maybe_paths = Dir.glob("#{f.etc}/*#{unversioned_name}*") - paths.to_a + maybe_paths = Dir.glob("#{f.etc}/*#{unversioned_name}*") + maybe_paths -= paths if paths.present? if maybe_paths.present? puts opoo <<~EOS