Skip to content

Info: hide older kegs#22897

Open
HaraldNordgren wants to merge 2 commits into
Homebrew:mainfrom
HaraldNordgren:info-hide-older-kegs
Open

Info: hide older kegs#22897
HaraldNordgren wants to merge 2 commits into
Homebrew:mainfrom
HaraldNordgren:info-hide-older-kegs

Conversation

@HaraldNordgren

@HaraldNordgren HaraldNordgren commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

I temporarily switched to my old laptop with outdated packages, and was confused about the output now, so thought I would improve it.

Only show the newest keg of each formula plus any linked keg in the "Installed Kegs and Versions" section by default. Older, non-linked kegs are listed only with --verbose.

$ brew info python
==> python@3.14 ↑: 3.7.1 → stable 3.14.6
...
==> Installed Kegs and Versions
python@3.9 ↑  3.9.4 → 3.9.25 (7,828 files, 121.3MB) [Linked]
python@3.14 ↑ 3.7.1 → 3.14.6 (3,904 files, 63.3MB)


$ brew info python -v
==> python@3.14 ↑: 3.7.1 → stable 3.14.6
...
==> Installed Kegs and Versions
python@3.9 ↑  3.9.4 → 3.9.25 (7,828 files, 121.3MB) [Linked]
  Built from source on 2021-04-11 at 22:10:27
python@3.14 ↑ 3.7.1 → 3.14.6 (3,904 files, 63.3MB)
  Poured from bottle on 2018-11-18 at 00:53:51
python@3.14 ↑ 3.6.4_4        (4,831 files, 105MB)
  Poured from bottle on 2018-03-10 at 12:12:56
python@3.14 ↑ 3.6.1          (3,807 files, 61MB)
  Poured from bottle on 2017-06-25 at 03:09:08
python@3.14 ↑ 2.7.14_2       (3,576 files, 51.8MB)
  Poured from bottle on 2018-02-04 at 12:50:32

  • 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.

Claude Code wrote the code as it iterated toward the solution.

Manually tested changes.


Only show the newest keg of each formula plus any linked keg in the
"Installed Kegs and Versions" section by default. Older, non-linked
kegs are listed only with --verbose.
When a formula's possible names include both a rack and a symlink to
that same rack (e.g. Cellar/python3 -> Cellar/python via the python3
alias), every keg under it was discovered once per name, so brew info
listed each installed version twice. Dedupe the Cellar directories by
their resolved physical path before collecting subdirs.
@HaraldNordgren HaraldNordgren changed the title Info hide older kegs Info: hide older kegs Jun 28, 2026
def self.formula_installed_prefixes(formula_names)
Array(formula_names).map { |formula_name| HOMEBREW_CELLAR/Utils.name_from_full_name(formula_name) }
.select(&:directory?)
.uniq(&:realpath)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Prevent a problem where kegs were showing up twice because of symlinking.

@carlocab carlocab 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.

I'm not convinced this is the right fix. In general, I think it is useful if brew info $formula shows all the installed versions kegs (the header does say ==> Installed Kegs and Versions after all).

The output you're seeing does seem pathological, but this seems to be atypical for brew info (usually it just shows older installed versions).

@HaraldNordgren

Copy link
Copy Markdown
Contributor Author

@carlocab I'm temporarily on an old machine that is stuck at macOS 12 and cannot be upgraded anymore, so Homebrew is does not officially support it. I hope that is not causing this.

The output you're seeing does seem pathological, but this seems to be atypical for brew info (usually it just shows older installed versions).

With that said, we recently changed how older versions are displayed, maybe that's why the output is expected for you?

The main problem with the old unliked version is that because brew switch doesn't exist anymore, there is not way to actually switch to them. So they are zombie versions, why do we need to display them? I thought I would keep them around inside of the verbose view just for correctness 😃

@HaraldNordgren

Copy link
Copy Markdown
Contributor Author

We can also change the header to be ==> Installed Versions

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