homebrew-bundle icon indicating copy to clipboard operation
homebrew-bundle copied to clipboard

feature request: support brew link --overwrite

Open tekumara opened this issue 3 years ago • 5 comments
trafficstars

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

tekumara avatar Feb 19 '22 07:02 tekumara

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.

MikeMcQuaid avatar Feb 21 '22 08:02 MikeMcQuaid

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 avatar Feb 22 '22 07:02 tekumara

@tekumara Yeh, I think you've convinced me here. Reopening and I'll review a PR for this.

MikeMcQuaid avatar Feb 22 '22 08:02 MikeMcQuaid

Nube question: after the issue is closed, would it be possible to apply this behaviour by default? E.g.:

brew_args link:overwrite

maxromanovsky avatar May 29 '22 13:05 maxromanovsky

would it be possible to apply this behaviour by default?

No, sorry.

MikeMcQuaid avatar May 30 '22 08:05 MikeMcQuaid

seems related

https://github.com/Mesa3D/mesa/actions/runs/3425503489/jobs/5706360682

How to getting github actions more reliable

lygstate avatar Nov 09 '22 04:11 lygstate

brew bundle --force can be used to accomplish this now.

MikeMcQuaid avatar Oct 06 '23 15:10 MikeMcQuaid