Homebrew / brew

🍺 The missing package manager for macOS (or Linux)
https://brew.sh
BSD 2-Clause "Simplified" License
41.51k stars 9.76k forks source link

Circular dependency checker fails if there's a name conflict between core and tap formulæ #7220

Closed bfontaine closed 4 years ago

bfontaine commented 4 years ago

What you were trying to do (and why)

Install a formula from an external tap that depends on a core formula which itself depends on a core formula with the same name as the first formula: homebrew-ffmpeg/ffmpeg/ffmpeg depends on chromaprint which depends on ffmpeg.

This is the issue, but you can reproduce it with any formula (see below): https://github.com/homebrew-ffmpeg/homebrew-ffmpeg/issues/13

brew install homebrew-ffmpeg/ffmpeg/ffmpeg

What happened (include command output)

Command output
==> Installing ffmpeg from homebrew-ffmpeg/ffmpeg
Error: homebrew-ffmpeg/ffmpeg/ffmpeg contains a recursive dependency on itself:
  homebrew-ffmpeg/ffmpeg/ffmpeg depends on chromaprint
  chromaprint depends on homebrew-ffmpeg/ffmpeg/ffmpeg
  

Notice the error message is wrong: chromaprint depends on the core ffmpeg, not homebrew-ffmpeg/ffmpeg/ffmpeg.

What you expected to happen

Homebrew shouldn’t have complained about this non-existent recursive dependency.

Step-by-step reproduction instructions (by running brew commands)

Create a dummy testa.rb formula in the core tap:

class Testa < Formula
  desc ""
  homepage ""
  url "file:///tmp/x"
  version "1"
  sha256 ""

  def install
  end
end

Create another dummy formula, testb.rb, that depends on the first one:

class Testb < Formula
  desc ""
  homepage ""
  url "file:///tmp/x"
  version "1"
  sha256 ""

  depends_on "testa"

  def install
  end
end

Now, in another tap, create a testa.rb formula that depends on testb:

class Testa < Formula
  desc ""
  homepage ""
  url "file:///tmp/x"
  version "1"
  sha256 ""

  depends_on "testb"

  def install
  end
end

Try to install this last formula:

# replace with your own tap
$ brew install bfontaine/utils/testa
==> Installing testa from bfontaine/utils
Error: bfontaine/utils/testa contains a recursive dependency on itself:
  bfontaine/utils/testa depends on testb
  testb depends on bfontaine/utils/testa

Here too notice the error message is wrong: testb depends on the core testa, not on bfontaine/utils/testa.

Output of brew config and brew doctor commands

$ brew config
HOMEBREW_VERSION: 2.2.10-114-gfa8fe0f
ORIGIN: gh:Homebrew/brew.git
HEAD: fa8fe0fc396550c23156043cd07550fc6ae6a27a
Last commit: 30 hours ago
Core tap ORIGIN: git@github.com:Homebrew/homebrew-core.git
Core tap HEAD: 9308b614f283d34ea6a42709edeb676367c6babf
Core tap last commit: 2 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_DEVELOPER: 1
HOMEBREW_GITHUB_API_TOKEN: set
HOMEBREW_INSTALL_CLEANUP: 1
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_POWERSEARCH_API_KEY: set
CPU: quad-core 64-bit haswell
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
Clang: 11.0 build 1100
Git: 2.26.0 => /usr/local/bin/git
Curl: 7.64.1 => /usr/bin/curl
Java: 1.8.0_131, 1.7.0_40
macOS: 10.15.3-x86_64
CLT: 11.0.33.17
Xcode: N/A
XQuartz: 2.7.11 => /opt/X11

$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Suspicious https://github.com/Homebrew/brew git origin remote found.
The current git origin is:
  gh:Homebrew/brew.git

With a non-standard origin, Homebrew won't update properly.
You can solve this by setting the origin remote:
  git -C "/usr/local/Homebrew" remote set-url origin https://github.com/Homebrew/brew

Warning: Suspicious https://github.com/Homebrew/homebrew-core git origin remote found.
The current git origin is:
  git@github.com:Homebrew/homebrew-core.git

With a non-standard origin, Homebrew won't update properly.
You can solve this by setting the origin remote:
  git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core" remote set-url origin https://github.com/Homebrew/homebrew-core

Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  ffmpeg

Warning: You have uncommitted modifications to Homebrew/homebrew-core.
If this is a surprise to you, then you should stash these modifications.
Stashing returns Homebrew to a pristine state but can be undone
should you later need to do so for some reason.
  cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core && git stash && git clean -d -f

Uncommitted files:
  ?? Formula/testa.rb
  ?? Formula/testb.rb
MikeMcQuaid commented 4 years ago

Homebrew shouldn’t have complained about this non-existent recursive dependency.

This is still a recursive dependency because, despite the hack that is Formula#full_name, both ffmpeg and homebrew-ffmpeg/ffmpeg/ffmpeg would be installed into the same Keg.