cask/audit: require "macho" before use - #23337
Merged
Merged
Conversation
Fixes "uninitialized constant Cask::Audit::MachO" during online audits. The min-OS binary check calls MachO.open but the gem was never required in this scope; load it lazily inline, matching os/mac/mach.rb. Signed-off-by: Rui Chen <rui@chenrui.dev>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Cask::Audit online cask audits raising uninitialized constant Cask::Audit::MachO by ensuring the macho gem is required before MachO.open is called in the bundle minimum-OS audit path.
Changes:
- Lazily
require "macho"immediately before callingMachO.openincask_bundle_min_os. - Prevents online
brew audit --cask --onlinefrom crashing when this code path is exercised.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
MikeMcQuaid
enabled auto-merge
July 28, 2026 13:56
This was referenced Jul 28, 2026
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.
brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?Fixes
uninitialized constant Cask::Audit::MachOraised during online cask audits.What
Cask::Audit#min_os_from_bundlecallsMachO.open(added in #20119) but themachogem was never required in this scope, so the constant is undefined when the min-OS binary check runs. This loads the gem lazily inline, matching the existing pattern inos/mac/mach.rb(which requires it at point of use to keep it off the Linux load path).Why
Any
brew audit --cask --onlinethat reaches the binary min-OS check crashes instead of auditing. This is currently breaking automated cask bump CI.Reproduce
Surfaced by Homebrew/homebrew-cask#277654 (failed CI run):
After this change the same command audits without raising.