Handle broken symlinks on install
, install --force
#21893
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While testing PR #21857 earlier today, I have found that
brew cask install
fails when it encounters a broken symlink, no matter if with or without--force
:Users might run into this in the wake of PR #21857, e. g. trying to move their Caskrooms around in an attempt to get
brew cask list
back working, or to merge their Caskrooms. One could argue that users are not supposed to do this, but we all know they will do it anyway. The issue will also bite unsuspecting users once PR #21858 is merged. Any legacy (pre-#13966) symlink pointing inside a custom Caskroom location is likely going to break.I feel that while
install
needs to fail gracefully,install --force
should do exactly what it says on the tin and sweep broken symlinks out of the way.This PR fixes both the
install
andinstall --force
case.Note that the
uninstall
andzap
cases have similar issues; those remain unfixed for the time being. Those cases have additional issues anyway, require a bit more effort to be fixed, and thus deserve a PR on their own.