Keg: only instantiate Keg.for if target exists

This commit is contained in:
Misty De Meo 2021-01-13 09:17:27 -08:00
parent 66f0a35587
commit a2e0da89e4

View File

@ -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