Skip to content

Warn about missing libraries in brew info#22849

Open
HaraldNordgren wants to merge 3 commits into
Homebrew:mainfrom
HaraldNordgren:info-missing-libraries-warning
Open

Warn about missing libraries in brew info#22849
HaraldNordgren wants to merge 3 commits into
Homebrew:mainfrom
HaraldNordgren:info-missing-libraries-warning

Conversation

@HaraldNordgren

@HaraldNordgren HaraldNordgren commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

This bit me when on an old version of ffmpeg, after upgrading it it started working. So I can't reproduce the exact issue.

But manually breaking a library to show what it looks like: mv /Users/Harald/git-repos/github.com/Homebrew/brew/Cellar/gmp/6.3.0/lib/libgmp.10.dylib{,.bak}

❯ ./bin/brew info gmp shellcheck
==> gmp ⚠: stable 6.3.0 (bottled), HEAD
GNU multiple precision arithmetic library
https://gmplib.org/
Installed (as dependency)
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/g/gmp.rb
License: LGPL-3.0-or-later OR GPL-2.0-or-later
==> Installed Kegs and Versions
gmp ✔ 6.3.0 (22 files, 3.4MB)
==> Dependencies
Missing libraries (1): libgmp.10.dylib ✘

==> shellcheck ✔: stable 0.11.0 (bottled), HEAD
Static analysis and lint tool, for (ba)sh scripts
https://www.shellcheck.net/
Installed (on request)
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/s/shellcheck.rb
License: GPL-3.0-or-later
==> Installed Kegs and Versions
shellcheck ✔ 0.11.0 (8 files, 68.4MB)
==> Dependencies
Required (1): gmp ⚠
Recursive Runtime (1): all installed ✔
Dependents: 1

  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • AI was used to generate or assist with generating this PR.

Claud Code wrote the code with my guidance.


When a dependency's soname bumps and the old dylib is removed, an
installed formula's binaries can be left linking against a library
that no longer exists, aborting at load time with a dyld error.

Surface this in the `brew info` Dependencies section for installed
formulae as a "Missing libraries" line, marking each library with a
red ✘ like other dependency statuses. The fix suggestion is
`brew upgrade` when the formula is outdated (which also relinks it)
and `brew reinstall` otherwise. The libraries are read from the
existing LinkageChecker, combining broken dependencies (dylibs under
opt/<dep>/) and broken dylibs that map to no dependency.
@github-actions

Copy link
Copy Markdown

Thanks for your pull request. This has been closed because it appears to use an incomplete or outdated pull request template.

Please edit this pull request to fill in the current pull request template. This workflow will reopen this pull request automatically once the template is complete. Do not open a new pull request for this.

@github-actions github-actions Bot closed this Jun 22, 2026
@HaraldNordgren

Copy link
Copy Markdown
Contributor Author

Benchmarks:

❯ hyperfine --warmup 3 --runs 15 \
  -L cache cold,warm \
  -L term 'gmp shellcheck' \
  -L sha 'main,info-missing-libraries-warning' \
  --prepare '
    mv /Users/Harald/git-repos/github.com/Homebrew/brew/Cellar/gmp/6.3.0/lib/libgmp.10.dylib{,.bak}
    set -e
    git checkout {sha}
    if [ "{cache}" = "cold" ]; then
      rm -f ~/Library/Caches/Homebrew/linkage.json
    fi
  ' \
  "./bin/brew info {term}"
Benchmark 1: ./bin/brew info gmp shellcheck (cache = cold, sha = main)
  Time (mean ± σ):     644.1 ms ±  10.9 ms    [User: 406.3 ms, System: 100.7 ms]
  Range (min … max):   627.9 ms … 664.3 ms    15 runs

Benchmark 2: ./bin/brew info gmp shellcheck (cache = warm, sha = main)
  Time (mean ± σ):     640.8 ms ±   8.7 ms    [User: 407.1 ms, System: 98.1 ms]
  Range (min … max):   629.1 ms … 652.0 ms    15 runs

Benchmark 3: ./bin/brew info gmp shellcheck (cache = cold, sha = info-missing-libraries-warning)
  Time (mean ± σ):     674.2 ms ±   8.1 ms    [User: 422.9 ms, System: 113.8 ms]
  Range (min … max):   658.3 ms … 683.5 ms    15 runs

Benchmark 4: ./bin/brew info gmp shellcheck (cache = warm, sha = info-missing-libraries-warning)
  Time (mean ± σ):     645.1 ms ±   7.4 ms    [User: 409.5 ms, System: 98.5 ms]
  Range (min … max):   635.5 ms … 655.8 ms    15 runs

Summary
  ./bin/brew info gmp shellcheck (cache = warm, sha = main) ran
    1.01 ± 0.02 times faster than ./bin/brew info gmp shellcheck (cache = cold, sha = main)
    1.01 ± 0.02 times faster than ./bin/brew info gmp shellcheck (cache = warm, sha = info-missing-libraries-warning)
    1.05 ± 0.02 times faster than ./bin/brew info gmp shellcheck (cache = cold, sha = info-missing-libraries-warning)

@github-actions github-actions Bot reopened this Jun 22, 2026

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Can you benchmark this on big formulae/those with lots of linkage e.g. ffmpeg-full, llvm, boost?

kegs = shadowing_formula ? [] : formula.installed_kegs
installed = kegs.any?
outdated = installed && formula.outdated?
missing_libraries, missing_library_deps = installed ? formula.missing_library_linkage : [[], Set.new]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid ternary here, I think it makes it harder to read. Would prefer ||= on both variables.

Comment thread Library/Homebrew/utils/output.rb Outdated
Comment thread Library/Homebrew/utils/output.rb Outdated
HaraldNordgren and others added 2 commits June 22, 2026 18:20
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants