{{ message }}
Require utils/analytics in cmd/info - #23833
Merged
Merged
Conversation
`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.
Contributor
There was a problem hiding this comment.
🟢 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/analyticsincmd/info.rb. - Removes dependency on test load order.
File summaries
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.
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.

Add the missing
utils/analyticsdependency tocmd/info.rb, which needs it due to calls toUtils::Analytics.output,Utils::Analytics.formula_outputandUtils::Analytics.cask_output— primarily inprint_analytics.The missing dependency does not cause issues at runtime because
brew.rbrequiresutils/analyticsbefore invoking commands, so the constant is always loaded. In the test suite, it is only defined if another spec requires it before thecmd/info_spec.rbruns. Running thecmd/infotests in isolation (brew tests --only=cmd/info) raisesuninitialized constant Utils::Analytics:To reproduce (before this change):
The fix is to
require "utils/analytics"incmd/info.rbdirectly, so the command loads its own dependency regardless of load order.brew benchmarkresults.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?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.