homebrew-bundle
homebrew-bundle copied to clipboard
feature request: support brew link --overwrite
To handle cases like:
Using kubernetes-cli
Linking kubernetes-cli formula.
Linking /usr/local/Cellar/kubernetes-cli/1.23.4...
Error: Could not symlink bin/kubectl
Target /usr/local/bin/kubectl
already exists. You may want to remove it:
rm '/usr/local/bin/kubectl'
To force the link and overwrite all conflicting files:
brew link --overwrite kubernetes-cli
To list all files that would be deleted:
brew link --overwrite --dry-run kubernetes-cli
link --force is supported (https://github.com/Homebrew/homebrew-bundle/blob/3b7cba3e1c32e5908f8f688033bd614195c020d7/lib/bundle/brew_installer.rb#L98). link --overwrite seems a bit dangerous to support in a DSL like this.
Thanks @MikeMcQuaid for taking a look at this.
I've tried --force but it produces the same error.
Our problem is that our brewfile includes:
cask docker
brew "kubernetes-cli"
brew "kubectx"
Docker installs an older version of kubectl to /Applications/Docker.app/Contents/Resources/bin/kubectl and links it to /usr/local/bin/kubectl. But we need kubernetes-cli as a depedency of kubectx, and also because it's newer than the Docker version.
It is possible to wrap the Brewfile in a bash script that does the overwrite, eg:
# install packages in Brewfile
brew bundle install --verbose --no-lock
# overwrite docker's kubectl because kubernetes-cli is newer
brew link --overwrite kubernetes-cli
But it would be more convenient if we could do the overwrite within the Brewfile.
@tekumara Yeh, I think you've convinced me here. Reopening and I'll review a PR for this.
Nube question: after the issue is closed, would it be possible to apply this behaviour by default? E.g.:
brew_args link:overwrite
would it be possible to apply this behaviour by default?
No, sorry.
seems related
https://github.com/Mesa3D/mesa/actions/runs/3425503489/jobs/5706360682
How to getting github actions more reliable
brew bundle --force can be used to accomplish this now.