brew icon indicating copy to clipboard operation
brew copied to clipboard

`--overwrite` should always overwrite links

Open JOJ0 opened this issue 4 months ago • 8 comments

Verification

  • [X] This issue's title and/or description do not reference a single formula e.g. brew install wget. If they do, open an issue at https://github.com/Homebrew/homebrew-core/issues/new/choose instead.

Provide a detailed description of the proposed feature

I'm sorry for posting this as an issue here, I would have rather opened a discussion about it, if that where available here. Sorry again, you might not like that I'm simply asking a question and am not sure if I even have a feature request.

homebrew on my machine takes quite some time for any package to install. And after "minutes" or even hours it stops continuing because it asks me questions like this:

Error: Could not symlink include/textstyle/stdbool.h
Target /usr/local/include/textstyle/stdbool.h
is a symlink belonging to gettext. You can unlink it:
  brew unlink gettext

To force the link and overwrite all conflicting files:
  brew link --overwrite gettext

To list all files that would be deleted:
  brew link --overwrite gettext --dry-run

Which I always answer by tediously copying and pasting. Yes please overwrite, I don't care!

So what I'm asking myself is, is there any options that allow to simply tell brew to just always overwrite links? I tried this but it doesn't seem to work. I still get stops during longish runs:

brew install --quiet --overwrite --force somepackage

If such an "always overwrite links" option currently is not available then this would actually be the feature I would like to request. Thanks for you consideration! Please get back to me with any thoughts, improvement suggestions of my workflow or criticism on my report! All welcome! Thanks a lot for your time and efforts!

JOJ0 avatar Mar 09 '24 10:03 JOJ0

I'm sorry for posting this as an issue here, I would have rather opened a discussion about it, if that where available here.

We do have a discussions page for these sorts of questions.

Does brew install --overwrite and/or brew upgrade --overwrite not do what you need it to?

carlocab avatar Mar 09 '24 15:03 carlocab

Probably need a specific example in order to provide context. Like what exact command you were running when it errored and at least some command output before the error.

Without any extra info, I am guessing this is related to linking dependencies since I think --overwrite should work but only for input formula. If so, as far as I can tell, we don't support this. A hack would be passing in everything in dependency tree $(brew deps ...), but that will result in a marking all formulae as installed_on_request and making it difficult to clean up no longer used formulae.

cho-m avatar Mar 10 '24 15:03 cho-m

I'm sorry for posting this as an issue here, I would have rather opened a discussion about it, if that where available here.

We do have a discussions page for these sorts of questions.

Does brew install --overwrite and/or brew upgrade --overwrite not do what you need it to?

I'm very sorry I missed that discussions is open in this repo.

As said: install --overwrite still asks when dependency link conflicts are happening.That usually happens with long running compiles. In the end it often takes me literally days to install one piece of software because every other dependency throws such a link overwrite conflict...

JOJ0 avatar Mar 11 '24 17:03 JOJ0

As said: install --overwrite still asks when dependency link conflicts are happening.That usually happens with long running compiles. In the end it often takes me literally days to install one piece of software because every other dependency throws such a link overwrite conflict...

Can you be more specific here?

MikeMcQuaid avatar Mar 11 '24 17:03 MikeMcQuaid

I'll post a report when not AFK

JOJ0 avatar Mar 11 '24 17:03 JOJ0

@MikeMcQuaid for example, I recently tried to install brew install nvim which is a very long running process on my machine, it downloads, compiles and does whatever brew requires to do to get this software, as well as all required dependencies installed.

Very often, if not all the time, I use brew to install anything, I get a similar experience: brew stops and asks me to solve "symlink overwrite conflicts" by hand.

I can't repro this specific install anymore, because after 2-3 reruns I'm finally through with manual linking solving.

With brew upgrade --overwrite I actually get the very same behaviour. It is a very long running process and after minutes or even hours, it stops because it is afraid to overwrite a symlink of a dependent software package:

$ brew upgrade --overwrite
...
...
...
==> Downloading https://curl.se/download/curl-8.6.0.tar.bz2
######################################################################################################################################################################################################################## 100.0%
==> Installing opus dependency: curl
==> Installing dependencies for curl: brotli, libunistring, libidn2, libnghttp2, ca-certificates, openssl@3, libssh2, openldap, rtmpdump and xz
==> Installing curl dependency: brotli
==> Downloading https://formulae.brew.sh/api/formula.jws.json
######################################################################################################################################################################################################################## 100.0%
==> cmake .
==> make VERBOSE=1
==> ctest -V
==> make install
==> Downloading https://formulae.brew.sh/api/cask.jws.json
######################################################################################################################################################################################################################## 100.0%
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/brotli
Target /usr/local/bin/brotli
is a symlink belonging to brotli. You can unlink it:
  brew unlink brotli

To force the link and overwrite all conflicting files:
  brew link --overwrite brotli

To list all files that would be deleted:
  brew link --overwrite brotli --dry-run

Possible conflicting files are:
/usr/local/bin/brotli -> /usr/local/Cellar/brotli/1.0.9/bin/brotli
Error: Could not symlink include/brotli/decode.h
Target /usr/local/include/brotli/decode.h
is a symlink belonging to brotli. You can unlink it:
  brew unlink brotli

To force the link and overwrite all conflicting files:
  brew link --overwrite brotli

To list all files that would be deleted:
  brew link --overwrite brotli --dry-run

Does that clarify what I'm asking?

JOJ0 avatar Mar 14 '24 08:03 JOJ0

Does that clarify what I'm asking?

Yes, thanks. It is indeed unexpected/a bug that brew upgrade --overwrite will not overwrite in this case. Reopening.

MikeMcQuaid avatar Mar 14 '24 08:03 MikeMcQuaid

==> Installing curl dependency: brotli
...
Possible conflicting files are:
/usr/local/bin/brotli -> /usr/local/Cellar/brotli/1.0.9/bin/brotli

This is confusing. Very strange that brotli can't handle brotli's own files.

May need to understand your setup better with brew config/brew doctor output.

cho-m avatar Mar 21 '24 16:03 cho-m