Skip to content

fix: fall back to stable deps when head_dependencies is absent#21762

Merged
MikeMcQuaid merged 5 commits intoHomebrew:mainfrom
costajohnt:fix/head-install-deps
Mar 19, 2026
Merged

fix: fall back to stable deps when head_dependencies is absent#21762
MikeMcQuaid merged 5 commits intoHomebrew:mainfrom
costajohnt:fix/head-install-deps

Conversation

@costajohnt
Copy link
Copy Markdown
Contributor

@costajohnt costajohnt commented Mar 19, 2026

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes?
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

  • AI was used to generate or assist with generating this PR. Claude Code was used as a coding assistant for investigation and implementation. All code was reviewed and verified manually, including running the test suite locally.

What does this PR do?

When Formula#dependencies_hash generates the API JSON, it intentionally omits head_dependencies when they're identical to stable deps (to save space). FormulaStructGenerator#generate_formula_struct_hash treated this absence as "no dependencies," passing nil to process_dependencies_and_requirements which returned empty arrays. This broke HEAD installs for any formula that inherits stable dependencies.

The fix falls back to stable_dependency_hash when hash["head_dependencies"] is nil, restoring the correct behavior where HEAD inherits stable deps unless explicitly overridden.

Fixes #21760

@costajohnt costajohnt marked this pull request as ready for review March 19, 2026 04:56
Copy link
Copy Markdown
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks @costajohnt!

@MikeMcQuaid MikeMcQuaid enabled auto-merge March 19, 2026 09:48
Copy link
Copy Markdown
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@costajohnt Looks like a legit test failure here.

Copy link
Copy Markdown
Member

@Rylan12 Rylan12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good once CI is good, thanks!

One suggestion: can we add a comment here? The correctness of this change was not obvious to me (although I've verified that it is correct), so this comment will help clarify why this is needed

@Rylan12
Copy link
Copy Markdown
Member

Rylan12 commented Mar 19, 2026

Note to self: this should also fix the same issue with HOMEBREW_REALLY_USE_INTERNAL_API once this gets through the formulae.brew.sh re-generation

When `dependencies_hash` generates the API JSON, it omits
`head_dependencies` when they equal stable deps (to save space).
`FormulaStructGenerator` treated this absence as "no dependencies,"
breaking HEAD installs that inherit stable dependencies.

Fall back to the stable dependency hash when `head_dependencies`
is nil.

Fixes Homebrew#21760
Include urls.stable.url in the test hash so generate_formula_struct_hash
can build a valid stable_url_args tuple for Sorbet. Accept Rylan12's
suggestion to add a comment explaining the head_dependencies fallback.
auto-merge was automatically disabled March 19, 2026 15:58

Head branch was pushed to by a user without write access

@costajohnt costajohnt force-pushed the fix/head-install-deps branch from 161afc6 to 5273745 Compare March 19, 2026 15:58
FormulaStruct requires desc, homepage, license, ruby_source_checksum,
and stable_version (via versions.stable). Without these, from_hash
raises a Sorbet ArgumentError for missing required props.
generate_formula_struct_hash calls dig("ruby_source_checksum", "sha256")
which expects the value to be a hash, not a plain string.
generate_formula_struct_hash works on a dup'd copy of the input,
so the original hash is never modified. Check the returned struct's
head_dependencies and stable_dependencies accessors instead.
@costajohnt costajohnt force-pushed the fix/head-install-deps branch from 50bc8e6 to 6e52208 Compare March 19, 2026 16:34
@MikeMcQuaid MikeMcQuaid enabled auto-merge March 19, 2026 16:42
@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Mar 19, 2026
Merged via the queue into Homebrew:main with commit e1875e5 Mar 19, 2026
36 checks passed
@costajohnt costajohnt deleted the fix/head-install-deps branch March 19, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Installing from HEAD fails to download dependencies

3 participants