Skip to content

List formula versions using bash - #24373

Merged
MikeMcQuaid merged 1 commit into
mainfrom
list-versions-bash
Oct 28, 2026
Merged

MikeMcQuaid merged 1 commit into
mainfrom
list-versions-bash

Conversation

@krehel

@krehel krehel commented Oct 28, 2026

Copy link
Copy Markdown
Member
  • brew list --versions <formula> and brew list --versions --formula started Ruby only to read directory names from the Cellar. Scripts often use the former to check whether formulae are installed.
  • list.sh now prints these for plain formula names, sorted as Ruby sorts them, or for every formula when --formula is given or no casks are installed.
  • Casks, aliases, renamed formulae, tap-qualified names, flags Ruby rejects alongside --versions and formulae with more than one version installed, which Ruby lists in directory order, still go to Ruby.

  • 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 brew benchmark results.
  • 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?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

Opus 5.5 xhigh with manual review and testing.

@krehel krehel changed the title List formula versions in bash List formula versions using bash Oct 28, 2026
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Summary

Summary by CodeRabbit

  • New Features
    • brew list --versions supports named formulae, including repeated names, and displays the installed version for each eligible formula.
  • Bug Fixes
    • Version listings handle supported formula and cask filters more consistently. Requests involving unsupported combinations, missing or path-like names, multiple installed versions, or listing flags are not reported as successful Bash listings and continue through the appropriate handling path.

The Bash homebrew-list command now handles supported formula version listings. It validates arguments, lists eligible formula versions, and returns unsupported requests to Ruby. Tests compare Bash and Ruby output and check fallback conditions.

Changes: Formula version listing

Layer / File(s) Summary
Eligibility, listing, and parity tests
Library/Homebrew/list.sh, Library/Homebrew/cmd/list.rb, Library/Homebrew/test/cmd/list_spec.rb
The Bash command validates version-listing arguments and calls homebrew-list-formula-versions. The function lists eligible formula versions or returns a fallback status. Tests compare Bash and Ruby results and cover unsupported inputs. Comments in the Ruby command point to the Bash implementation.

Priority: Low

Merge Risk: Moderate · up to e79cf

With this change, brew list --versions --formula can abort on macOS's system Bash when the Cellar has no formulae, rather than printing nothing. The case is narrow and easy to fix with an empty-array guard plus a regression test. It should be fixed before merge.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly describes the main change: using Bash to list formula versions.
Description check Passed The description explains the Bash fast path, its scope, fallback cases, motivation, and testing claims. It directly relates to the changeset.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2c719050-561a-4f7f-82f6-f14eaf9614ff
Commits

Reviewing files that changed from the base of the PR and between a59d9fc and 2b3edc2.

Files selected for processing: 3
  • Library/Homebrew/cmd/list.rb
  • Library/Homebrew/list.sh
  • Library/Homebrew/test/cmd/list_spec.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread Library/Homebrew/list.sh Resolved
- `brew list --versions <formula>` and `brew list --versions --formula`
  started Ruby only to read directory names from the Cellar. Scripts
  often use the former to check whether formulae are installed.
- `list.sh` now prints these for plain formula names, sorted as Ruby
  sorts them, or for every formula when `--formula` is given or no
  casks are installed.
- Casks, aliases, renamed formulae, tap-qualified names, flags Ruby
  rejects alongside `--versions` and formulae with more than one
  version installed, which Ruby lists in directory order, still go to
  Ruby.
@krehel
krehel force-pushed the list-versions-bash branch from 2b3edc2 to e79cfc0 Compare October 28, 2026 02:53

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Major · Guard the empty racks expansion. · list.sh:331

Library/Homebrew/list.sh:331
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Guard the empty racks expansion.

On macOS Bash 3.2, brew list --versions --formula aborts when the Cellar has no racks. bin/brew enables nounset, and expanding an empty array causes an unbound-variable error before Ruby can handle the request. (raw.githubusercontent.com)

Guard the expansion and test this case with nounset enabled.


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 624d9eaf-0d2a-4d88-b3f0-e2b90eb145b1
Commits

Reviewing files that changed from the base of the PR and between 2b3edc2 and e79cfc0.

Files selected for processing: 2
  • Library/Homebrew/list.sh
  • Library/Homebrew/test/cmd/list_spec.rb

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

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

Nice, thanks!

@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Oct 28, 2026
Merged via the queue into main with commit 3a71098 Oct 28, 2026
54 checks passed
@MikeMcQuaid
MikeMcQuaid deleted the list-versions-bash branch October 28, 2026 08:49
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