Remove LinkedKegs entry if we're writing the same one

If a keg has been uninstalled via `rm -rf <keg>`, and a user tries to
reinstall it without `brew unlink`ing it first, it will fail to link as
the LinkedKegs entry still exists. This isn't desirable, and the user
should be able to reinstall the same formula on top of the old, dead
symlinks without problems, so let's just remove the LinkedKegs entry if
it matches the one we are installing anyway.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
Jack Nagel 2012-02-10 23:40:21 -06:00
parent c1fecab365
commit cdd52e28f1

View File

@ -104,6 +104,7 @@ module Homebrew extend self
fi = FormulaInstaller.new(f)
fi.install
fi.caveats
f.linked_keg.unlink if f.linked_keg.directory? and f.linked_keg.realpath == f.prefix
fi.finish
rescue FormulaAlreadyInstalledError => e
opoo e.message