Skip to content

link and conflicts_with options do not work as expected #1442

Open
@ahawkins

Description

From the docs:

# 'brew install', always 'brew services restart', 'brew link', 'brew unlink mysql' (if it is installed)
brew "[email protected]", restart_service: true, link: true, conflicts_with: ["mysql"]

We want [email protected] installed and linked. So we have this in our Brewfile:

brew '[email protected]', link: true, conflicts_with: ["mysql"]

This does not work. The linking fails. Here's what happens.

$ brew install mysql
$ brew bundle
Using [email protected]
Error: Could not symlink bin/comp_err
Target /opt/homebrew/bin/comp_err
is a symlink belonging to mysql. You can unlink it:
  brew unlink mysql

To force the link and overwrite all conflicting files:
  brew link --overwrite [email protected]

To list all files that would be deleted:
  brew link --overwrite [email protected] --dry-run
Linking /opt/homebrew/Cellar/[email protected]/8.0.39_1...
Homebrew Bundle complete! 1 Brewfile dependency now installed.
$ echo $?
0

The linking fails. Also brew bundle incorrectly exits with status code 0 for successful execution. This is not true.

The docs reference a -f to force overwriting. This also does not work as expected. The brew link step fails in the same way:

$ brew bundle -f
Using [email protected]
Error: Could not symlink bin/comp_err
Target /opt/homebrew/bin/comp_err
is a symlink belonging to mysql. You can unlink it:
  brew unlink mysql

To force the link and overwrite all conflicting files:
  brew link --overwrite [email protected]

To list all files that would be deleted:
  brew link --overwrite [email protected] --dry-run
Linking /opt/homebrew/Cellar/[email protected]/8.0.39_1...
Homebrew Bundle complete! 1 Brewfile dependency now installed.
$ echo $?
0

Note the command still exits 0 even though a part failed.

The only way to resolve the issue is to manually run brew unlink mysql prior to brew bundle. This apparently defeats the purpose of the link and conflicts_with options.

$ brew unlink mysql
Unlinking /opt/homebrew/Cellar/mysql/9.0.1... 97 symlinks removed.
$ brew bundle
Using [email protected]
Homebrew Bundle complete! 1 Brewfile dependency now installed.
$ mysql --version
mysql  Ver 8.0.39 for macos14.4 on arm64 (Homebrew)

This issue seems similar to #932.

My Current bundle version

git:master >> pwd
/opt/homebrew/Library/Taps/homebrew/homebrew-bundle
git:master >> git show
commit 980753399e0bc5802610cd1eeacdb16cba53744b (HEAD -> master, origin/master, origin/HEAD)
Merge: d368f81 c33837a
Author: Patrick Linnane <[email protected]>
Date:   Tue Sep 3 15:15:48 2024 -0700

    Merge pull request #1441 from Homebrew/dependabot/bundler/rspec-core-3.13.1

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions