Repository navigation
list: fail clearly for uninstalled casks when piped - #24345
Merged
MikeMcQuaid merged 1 commit intoOct 24, 2026
Merged
Conversation
When stdout is not a TTY (or with `--verbose`), `brew list --cask NAME` ran `find` on the Caskroom path even if the cask was not installed, so it failed with a `find` execution error instead of the "Cask 'NAME' is not installed." error the TTY path gives. Raise `CaskNotInstalledError` before running `find`, as `Cask::List.list_casks` does.
Contributor
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Check cask installation before listing paths Library/Homebrew/cmd/list.rb, Library/Homebrew/test/cmd/list_spec.rb |
The command raises CaskNotInstalledError for the first uninstalled cask before listing cask paths. The test checks the error message and confirms that stdout is empty. |
Priority:
Merge Risk: 
Minimal · up to e7539
-
No actionable merge-blocking risk is established.
Pre-merge checks: 
4
- 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.
Comment @coderabbitai help to get the list of available commands.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
brew benchmarkresults.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?Claude Opus 5.5 found the cause, wrote the one-line fix and the spec, and ran the checks below. I reviewed the diff and the before/after output myself.
When stdout is not a TTY, or with
--verbose,brew list --caskrunsfindon each named cask's Caskroom directory without checking that the cask is installed. For a cask that isn't installed you get afindfailure instead of the normal error:In a terminal the same command prints
Error: Cask 'crossover' is not installed., and formulae already fail cleanly on both paths. This matters for scripts that pipebrew listoutput.To reproduce, with a cask that isn't installed:
brew list --cask crossover | catbrew list --cask --verbose crossoverThis raises
Cask::CaskNotInstalledErrorbefore runningfind, the same checkCask::List.list_casksdoes for the TTY path. Installed casks still list their files. After the change both commands printError: Cask 'crossover' is not installed.and exit 1.Locally
brew lgtmpasses. The new example inbrew tests --only=cmd/listfails onmainwith thefinderror and passes with this change.