From a2e0da89e4e1ae7f815210eb2d30d68114520e5c Mon Sep 17 00:00:00 2001 From: Misty De Meo Date: Wed, 13 Jan 2021 09:17:27 -0800 Subject: [PATCH] Keg: only instantiate Keg.for if target exists --- Library/Homebrew/keg.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 99c0e02559..aa406c0bf8 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -651,7 +651,7 @@ class Keg # formula. The `AlreadyLinkedError` above won't catch # this if a formula is missing an optlink. In that case, # delete the symlink and retry. - if dst.symlink? && Keg.for(dst).name == name + if dst.symlink? && dst.exist? && Keg.for(dst).name == name dst.unlink retry end