Skip to content

Fix build.rb receiving formula.jws.json instead of .rb source path#22034

Merged
MikeMcQuaid merged 1 commit into
mainfrom
fix/build-rb-jws-json-path
Apr 17, 2026
Merged

Fix build.rb receiving formula.jws.json instead of .rb source path#22034
MikeMcQuaid merged 1 commit into
mainfrom
fix/build-rb-jws-json-path

Conversation

@p-linnane
Copy link
Copy Markdown
Member

@p-linnane p-linnane commented Apr 17, 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? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you written new tests (excluding integration tests) for your changes? Here's an example.
  • 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. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes. Non-maintainers may only have one AI-assisted/generated PR open at a time.

Debugged with Claude Opus 4.7. Verified locally.


Fixes https://github.com/orgs/Homebrew/discussions/6455

On Tier-3 systems (no bottles available), FormulaInstaller#build passes formula.specified_path to build.rb. If the async API to source formula swap failed silently, specified_path still points at formula.jws.json, producing FormulaUnavailableError: formula.jws.json.

Adds defense-in-depth guards at source_download_formula, FormulaInstaller#build, and build.rb, each with actionable error messages so users aren't left with a cryptic failure.

Copilot AI review requested due to automatic review settings April 17, 2026 02:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes source builds on Tier-3 systems where FormulaInstaller#build can end up invoking build.rb with the JSON API file path (formula.jws.json) instead of a .rb formula source path, producing a confusing FormulaUnavailableError.

Changes:

  • Add a fallback in FormulaInstaller#build to synchronously download/load the formula Ruby source when the formula is still API-loaded.
  • Add a guard in build.rb to fail fast with an actionable error if the passed “formula path” isn’t a .rb file.
  • Harden API source download behavior by refetching when the cached “symlink location” is not actually a symlink, and by raising when the expected source path is still missing.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
Library/Homebrew/formula_installer.rb Ensures API-loaded formulae are converted to a source-backed .rb before invoking build.rb.
Library/Homebrew/build.rb Validates the received formula path to avoid cryptic failures when a JSON path is passed.
Library/Homebrew/api/formula.rb Tightens API source download/cache handling and adds a missing-source guard.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Library/Homebrew/api/formula.rb Outdated
Comment thread Library/Homebrew/formula_installer.rb Outdated
Comment thread Library/Homebrew/api/formula.rb Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Library/Homebrew/test/api/formula_spec.rb
Comment thread Library/Homebrew/test/formula_installer_spec.rb
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Library/Homebrew/build.rb Outdated
Signed-off-by: Patrick Linnane <patrick@linnane.io>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Library/Homebrew/test/formula_installer_spec.rb
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.

Thanks!

@MikeMcQuaid MikeMcQuaid enabled auto-merge April 17, 2026 08:02
@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Apr 17, 2026
Merged via the queue into main with commit f8b3029 Apr 17, 2026
59 of 60 checks passed
@MikeMcQuaid MikeMcQuaid deleted the fix/build-rb-jws-json-path branch April 17, 2026 08:36
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.

3 participants