Skip to content

brew upgrade misbehaves when a formula's dependency is renamed #1770

@cartr

Description

@cartr
  • Ran brew update and retried your prior step?
  • Ran brew doctor, fixed as many issues as possible and retried your prior step?
  • Confirmed this is problem with Homebrew/brew and not specific formulae? If it's a formulae-specific problem please file this issue at https://github.com/Homebrew/homebrew-core/issues/new

Here's my brew config and brew doctor output.

Summary

If a formula (that is depended on by another installed formula) is renamed, brew update tries to install it on top of the old one and fails during the brew link step.

Steps to Reproduce

Run these commands:

brew tap cartr/rename-bug-demo
brew install dependent

You'll get two new formulae installed: somepackage (which is GNU Hello) and dependent which depends on it. Next, run these to switch to a branch where somepackage has been renamed to somepackage4 and upgrade:

cd /usr/local/Homebrew/Library/Taps/cartr/homebrew-rename-bug-demo
git config --add remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" && git fetch
git checkout add-four
brew upgrade

Expected Result

The upgrade completes successfully, migrating somepackage to somepackage4.

Actual Result

bash-3.2$ brew upgrade
Warning: You are using a pre-release version of Xcode.
You may encounter build failures or other breakages.
Please create pull-requests instead of filing issues.
==> Upgrading 1 outdated package, with result:
cartr/rename-bug-demo/somepackage4 2.10_1
==> Upgrading cartr/rename-bug-demo/somepackage4
==> Downloading http://ftpmirror.gnu.org/hello/hello-2.10.tar.gz
==> Downloading from http://mirrors.kernel.org/gnu/hello/hello-2.10.tar.gz
######################################################################## 100.0%
==> ./configure --disable-silent-rules --prefix=/usr/local/Cellar/somepackage4/2.10_1
==> make install
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/hello
Target /usr/local/bin/hello
is a symlink belonging to somepackage. You can unlink it:
  brew unlink somepackage

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

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

Possible conflicting files are:
/usr/local/bin/hello -> /usr/local/Cellar/somepackage/2.10_1/bin/hello
/usr/local/share/info/hello.info -> /usr/local/Cellar/somepackage/2.10_1/share/info/hello.info
/usr/local/share/man/man1/hello.1 -> /usr/local/Cellar/somepackage/2.10_1/share/man/man1/hello.1
==> Summary
🍺  /usr/local/Cellar/somepackage4/2.10_1: 10 files, 124.4K, built in 41 seconds

somepackage remains installed in its original location. somepackage4 is installed but unlinked.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedWe want help addressing this

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions