Skip to content

Require utils/analytics in cmd/info - #23833

Merged
MikeMcQuaid merged 1 commit into
Homebrew:mainfrom
waldyrious:info-require-analytics
Sep 6, 2026
Merged

Require utils/analytics in cmd/info#23833
MikeMcQuaid merged 1 commit into
Homebrew:mainfrom
waldyrious:info-require-analytics

Conversation

@waldyrious

@waldyrious waldyrious commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Add the missing utils/analytics dependency to cmd/info.rb, which needs it due to calls to Utils::Analytics.output, Utils::Analytics.formula_output and Utils::Analytics.cask_output — primarily in print_analytics.

The missing dependency does not cause issues at runtime because brew.rb requires utils/analytics before invoking commands, so the constant is always loaded. In the test suite, it is only defined if another spec requires it before the cmd/info_spec.rb runs. Running the cmd/info tests in isolation (brew tests --only=cmd/info) raises uninitialized constant Utils::Analytics:

NameError: uninitialized constant Utils::Analytics
# ./cmd/info.rb:630:in 'Homebrew::Cmd::Info#info_formula'

To reproduce (before this change):

brew tests --only=cmd/info

The fix is to require "utils/analytics" in cmd/info.rb directly, so the command loads its own dependency regardless of load order.


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

I used Claude Opus 4.8 to help diagnose and fix this; I reviewed all output and confirmed the reproduction above failed before this change and passed after.

`cmd/info.rb` calls e.g. `Utils::Analytics.formula_output`
but never requires the file that defines it.

At runtime this is masked, since `brew.rb` requires `utils/analytics` early,
so the constant is always loaded. In the test suite it is only defined
if a co-loaded spec requires it (directly or transitively).
Running `cmd/info` in isolation (e.g. `brew tests --only=cmd/info`)
therefore raises `uninitialized constant Utils::Analytics`.

This patch fixes that error by requiring the file directly, mirroring `cask/info.rb`,
so the command loads its own dependency regardless of load order.
Copilot AI balanced review requested due to automatic review settings September 5, 2026 23:37

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.

🟢 Approval recommended

The dependency fix is focused and no unresolved issues were found.

Pull request overview

Adds the missing direct analytics dependency to brew info, preventing isolated test failures.

Changes:

  • Requires utils/analytics in cmd/info.rb.
  • Removes dependency on test load order.
File summaries
File Description
Library/Homebrew/cmd/info.rb Loads the analytics module used by info output paths.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

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

@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Sep 6, 2026
Merged via the queue into Homebrew:main with commit b83f418 Sep 6, 2026
54 checks passed
@waldyrious
waldyrious deleted the info-require-analytics branch September 6, 2026 08:33
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