Skip to content

cmd/deps: accept --brewfile as an input source#23104

Merged
andrew merged 2 commits into
Homebrew:mainfrom
andrew:deps-brewfile
Jul 14, 2026
Merged

cmd/deps: accept --brewfile as an input source#23104
andrew merged 2 commits into
Homebrew:mainfrom
andrew:deps-brewfile

Conversation

@andrew

@andrew andrew commented Jul 14, 2026

Copy link
Copy Markdown
Member

Adds --brewfile to brew deps, matching the flag on brew vulns. brew and cask entries from the Brewfile are treated as if they'd been passed as named arguments, so the flag composes with --tree, --graph, --for-each, --union and the default flat listing. --formula/--cask filter which entry types are loaded; tap, mas and other extension entries are ignored.

A bare --brewfile reads ./Brewfile; --brewfile=<path> reads a specific file.

$ cat Brewfile
brew "jq"
brew "wget"

$ brew deps --tree --brewfile
jq
└── oniguruma

wget
├── libidn2
│   ├── libunistring
│   └── gettext
│       ├── json-c
│       └── libunistring
├── libpsl
├── openssl@3
│   └── ca-certificates
├── gettext
│   ├── json-c
│   └── libunistring
└── libunistring

Motivation: seeing what a Brewfile will pull in before running brew bundle, and inspecting a project's toolchain footprint in CI without installing anything.

The brewfile_path normalisation helper is copied from cmd/vulns.rb; happy to extract it if a third command grows the same flag.


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

Written with Claude Code; I read the diff, exercised --tree, --graph --dot, --for-each, --union, and --formula/--cask filtering against a local Brewfile, and ran brew lgtm locally.


Read brew and cask entries from a Brewfile and treat them as if they
had been passed as named arguments, so --brewfile composes with --tree,
--graph, --for-each, --union and the default flat listing. --formula and
--cask filter which entry types are loaded. A bare --brewfile reads
./Brewfile and --brewfile=<path> reads a specific file, matching
brew vulns.
Copilot AI review requested due to automatic review settings July 14, 2026 14:21

Copilot AI 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.

Pull request overview

This PR adds --brewfile support to brew deps, allowing dependency output modes (--tree, --graph, --for-each, --union, and default listing) to use formulae/casks from a Brewfile as inputs, similar to brew vulns.

Changes:

  • Add --brewfile flag to brew deps and load formula/cask entries from a Brewfile as command inputs.
  • Add an integration spec covering --brewfile=<path>.
  • Update manpage/docs and shell completions to document the new flag.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Library/Homebrew/cmd/deps.rb Implements --brewfile flag and Brewfile-driven input loading for dependency calculation/output.
Library/Homebrew/test/cmd/deps_spec.rb Adds an integration test verifying --brewfile=<path> behavior with --tree.
Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/deps.rbi Adds the brewfile args accessor to the generated RBI for brew deps.
manpages/brew.1 Documents brew deps --brewfile in the main manpage.
docs/Manpage.md Documents brew deps --brewfile in the Markdown manpage source.
completions/zsh/_brew Adds --brewfile to zsh completions for brew deps.
completions/fish/brew.fish Adds --brewfile to fish completions for brew deps.
completions/bash/brew Adds --brewfile to bash completions for brew deps.
Files not reviewed (1)
  • Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/deps.rbi: File type not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Library/Homebrew/cmd/deps.rb
Comment thread Library/Homebrew/cmd/deps.rb
Comment thread Library/Homebrew/test/cmd/deps_spec.rb Outdated

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

Looks good thanks!

Previously --brewfile silently replaced any named arguments; combine
them instead so `brew deps foo --brewfile` includes foo alongside the
Brewfile entries, and dedupe the merged list.
@andrew andrew added this pull request to the merge queue Jul 14, 2026
Merged via the queue into Homebrew:main with commit 19a23e1 Jul 14, 2026
43 checks passed
@andrew andrew deleted the deps-brewfile branch July 14, 2026 16:27
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.

3 participants