Fix incorrect depends_on: macos serialization in JSON API for Linux variations#22137
Conversation
There was a problem hiding this comment.
Pull request overview
This PR removes the previously-added implicit depends_on macos: ">= …" from casks that don’t explicitly declare a macOS dependency, and fixes the API serialization/parsing path so that a bare depends_on :macos round-trips cleanly (including variations).
Changes:
- Remove the implicit macOS dependency injection for casks without an explicit
depends_on :macos. - Change
MacOSRequirement#to_hso a bare macOS requirement serializes as{}(not{">=" => [""]}) and teachCaskStructGenerator.process_depends_onto interpret that as:any. - Update cask JSON fixtures and add/extend specs for bare
depends_on :macosand Linux-variation behavior.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Library/Homebrew/cask/dsl.rb | Removes the private helper that injected an implicit macOS dependency into casks. |
| Library/Homebrew/cask/cask.rb | Stops calling the removed implicit-dependency helper during cask refresh. |
| Library/Homebrew/requirements/macos_requirement.rb | Adjusts macOS requirement hash serialization for the bare/no-version case. |
| Library/Homebrew/api/cask/cask_struct_generator.rb | Handles empty/bare macOS requirement hashes when reconstructing depends_on args. |
| Library/Homebrew/test/cask/dsl_spec.rb | Adds an assertion for the new bare-macos to_h serialization behavior. |
| Library/Homebrew/test/api/cask/cask_struct_generator_spec.rb | Adds coverage for process_depends_on converting bare macOS requirements to :any. |
| Library/Homebrew/test/cask/cask_spec.rb | Adds a spec asserting Linux variations don’t include a depends_on entry. |
| Library/Homebrew/test/support/fixtures/cask/everything.json | Updates expected API fixture output to remove the implicit macOS dependency. |
| Library/Homebrew/test/support/fixtures/cask/everything-with-variations.json | Same as above, for the variations fixture. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Nice work, I was thinking about doing this myself. I think the test failures are coming from filter_runners falling back to RUNNERS.dup after removing the implicit macOS dependency. That lets Linux runners leak into cases that should still default to macOS-only CI. A decent fix might making the fallback MACOS_RUNNERS.dup instead, then keep adding Linux runners later only when cask.supports_linux? is true. |
60c5f61 to
0ea9cff
Compare
Rylan12
left a comment
There was a problem hiding this comment.
I haven't looked into this yet, but I will when I have a sec.
which inadvertently forced
macos >= HOMEBREW_MACOS_OLDEST_ALLOWEDon all casks lacking an explicit macOS dependency
This was not inadvertently added, it's what was supposed to happen. I'm not up to date on the newest cask/Linux support, so not sure how to handle this. @SMillerDev or @MikeMcQuaid, can you clarify where we stand currently Linux/cask support wise
|
@Rylan12 We're in a non-ideal state:
|
|
This was our initial stopgap to prevent adding a I do think it would be beneficial to make a public note of this change in the default somewhere. Blog, social media, pinned discussion or otherwise because it will cause some confusion for tap owners. |
There was a problem hiding this comment.
API-related code looks good to me.
I'll let someone else make the final call on whether to remove the injected dependency or not, but it seems like removing it is appropriate given that we've mass-added depends_on :macos
A few comments/questions, but pretty much good to go
To be clear, I've only added I'm addressing that in #22146. If/when that's merged, I'll go through casks using It may also be a good idea to finish #22080 before dropping the implicit macOS dependency, though someone correct me if I'm wrong. That is to say, we're updating casks in homebrew/cask but we need audits to help ensure that new casks in homebrew-cask add |
@samford Thanks, that would be great! We've encountered them already but just not in homebrew/cask CC @SMillerDev who can probably point some out.
I'd rather we didn't block PRs on others that are in draft. We have sufficient logic we can use here today. It's not perfect but better than nothing. |
macos >= dependency from casks without explicit depends_on :macosdepends_on: macos serialization in JSON API for Linux variations
…serialization
- Remove `add_implicit_macos_dependency` which forced `macos >= 10.15` on
all casks without an explicit macOS dependency
- Fix `MacOSRequirement#to_h` to return `{}` for bare `depends :macos`
(no version specified) instead of `{">=" => [""]}`
- Fix `CaskStructGenerator.process_depends_on` to handle empty hash from
bare `depends :macos`, correctly serializing it as `:any`
- Update test fixtures to remove the now-unnecessary implicit macOS dependency
- Add tests for bare `depends :macos` and Linux variation behavior
- info_spec: local-transmission no longer has macOS requirement in output - installer_spec: use cask with explicit depends_on macos for requirement stub test
- generate-cask-ci-matrix: fallback to MACOS_RUNNERS.dup instead of RUNNERS.dup when no macOS version filter matches, preventing Linux runners from leaking into macOS-only cask CI - info_spec: remove expectations of implicit macOS >= 10.15 requirement from casks without explicit depends_on :macos - installer_spec: use cask with explicit depends_on macos for requirement stub test
… variations Use API.merge_variations to simulate different platforms when checking that Linux variations don't include macOS dependencies. This ensures the test works correctly regardless of which platform it runs on. Also rename test to accurately reflect it only checks for macOS dependency exclusion, not all depends_on.
c4234ea to
60b4f23
Compare
|
It appears a circular reference has occurred. |
ce4dc54 to
a09643a
Compare
|
Thanks @hangone! |
depends_on: macosfor Linux variations.MacOSRequirement#to_hto return{}for baredepends :macos(no version specified) instead of{">=" => [""]}for Fix cask page rendering macOS requirements formulae.brew.sh#2187CaskStructGenerator.process_depends_onto handle empty hash from baredepends :macos, correctly serializing it as:anydepends :macosand Linux variation behaviorAccording to #22080, formulas and casks that do not specify
depends_onare treated as being supported on both macOS and Linux. But fordepends_on :macos(#22006), should we default to displayingmacOS >= HOMEBREW_MACOS_OLDEST_ALLOWED, or simply retainmacOS?brew lgtm(style, typechecking and tests) with your changes locally?Claude Code for code, I review and create the PR.