Fix build.rb receiving formula.jws.json instead of .rb source path#22034
Conversation
There was a problem hiding this comment.
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#buildto synchronously download/load the formula Ruby source when the formula is still API-loaded. - Add a guard in
build.rbto fail fast with an actionable error if the passed “formula path” isn’t a.rbfile. - 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.
23228b1 to
495f91e
Compare
There was a problem hiding this comment.
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.
495f91e to
f3a6566
Compare
There was a problem hiding this comment.
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.
Signed-off-by: Patrick Linnane <patrick@linnane.io>
f3a6566 to
e036477
Compare
There was a problem hiding this comment.
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.
brew lgtm(style, typechecking and tests) with your changes locally?Debugged with Claude Opus 4.7. Verified locally.
Fixes https://github.com/orgs/Homebrew/discussions/6455
On Tier-3 systems (no bottles available),
FormulaInstaller#buildpassesformula.specified_pathtobuild.rb. If the async API to source formula swap failed silently,specified_pathstill points atformula.jws.json, producingFormulaUnavailableError: formula.jws.json.Adds defense-in-depth guards at
source_download_formula,FormulaInstaller#build, andbuild.rb, each with actionable error messages so users aren't left with a cryptic failure.