cask/artifact/pkg: fix type error#22923
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a Sorbet type error in the Cask pkg artifact installer path by ensuring the environment variables passed to SystemCommand.run! are typed as strings.
Changes:
- Convert
User.currentto a string before populatingenv:for/usr/sbin/installer. - Reuse the converted value across
LOGNAME/USER/USERNAMEto satisfySystemCommand’s Sorbet signature.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f9e8d99 to
6ebdb75
Compare
p-linnane
approved these changes
Jul 2, 2026
p-linnane
left a comment
Member
There was a problem hiding this comment.
This looks good. The remaining gap seems to be in Library/Homebrew/test/cask/artifact/pkg_spec.rb, since the existing expectation can still pass with a User delegator.
How about something like this in the spec?:
current_user = User.current&.to_s
env: {
"LOGNAME" => an_instance_of(String).and(eq(current_user)),
"USER" => an_instance_of(String).and(eq(current_user)),
"USERNAME" => an_instance_of(String).and(eq(current_user)),
}
Member
Author
|
Nice, that seems to do what we're looking for. Added in the latest push 👍 |
Member
|
This PR should unblock CI here: #22927 |
When the `HOMEBREW_SORBET_RECURSIVE=1` environment variable is set and a cask using the `pkg` stanza is installed/upgraded, Sorbet will give a type error (`Parameter 'env': Expected type T::Hash[String, T.nilable(T.any(PATH, String, T::Boolean))], got T::Hash[String, User]`) related to `SystemCommand.run!`. I looked for usage of `User` in cask and saw that `Cask::Artifact::Pkg.run_installer` uses `User` objects in the `env` arg to `SystemCommand.run!`. This resolves the issue by calling `#to_s` on `User.current`, to ensure it's a string.
Co-authored-by: Patrick Linnane <patrick@linnane.io>
cbbbe2d to
746fa0a
Compare
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?When the
HOMEBREW_SORBET_RECURSIVE=1environment variable is set and a cask using thepkgstanza is installed/upgraded, Sorbet will give a type error (Parameter 'env': Expected type T::Hash[String, T.nilable(T.any(PATH, String, T::Boolean))], got T::Hash[String, User]) related toSystemCommand.run!. I looked for usage ofUserin cask and saw thatCask::Artifact::Pkg.run_installerusesUserobjects in theenvarg toSystemCommand.run!. This resolves the issue by calling#to_sonUser.current, to ensure it's a string.You can replicate this by setting the
HOMEBREW_SORBET_RECURSIVE=1environment variable and installing/upgrading a cask that uses thepkgstanza (e.g.,HOMEBREW_SORBET_RECURSIVE=1 brew install cloudflare-warp).