Skip to content

fix(bootstrap): install Xcode Metal Toolchain on macOS (#9996)#10017

Open
lonexreb wants to merge 2 commits intowarpdotdev:masterfrom
lonexreb:fix/9996-bootstrap-metal-toolchain
Open

fix(bootstrap): install Xcode Metal Toolchain on macOS (#9996)#10017
lonexreb wants to merge 2 commits intowarpdotdev:masterfrom
lonexreb:fix/9996-bootstrap-metal-toolchain

Conversation

@lonexreb
Copy link
Copy Markdown
Contributor

@lonexreb lonexreb commented May 4, 2026

Fixes #9996.

crates/warpui/build.rs invokes the metal compiler to translate shader sources to .air at cargo-build time. Xcode 16 split the Metal Toolchain into a separately-downloadable component that is not installed by Xcode's default first-launch setup, so a fresh macOS dev box following `./script/bootstrap` then `./script/run` fails partway through cargo with a confusing build-script panic deep in the output:

error compiling metal shaders to .air; error: error: cannot execute tool 'metal' due to missing Metal Toolchain;
use: xcodebuild -downloadComponent MetalToolchain

This is the macOS counterpart to #9544 (Node.js / yarn check on Linux / Windows, fixed in #9669) — same pattern, different platform: catch a missing build-time tool during bootstrap rather than during cargo build, where the user is least equipped to diagnose it.

What's in the diff

  • xcrun --find metal probes for the toolchain (fast, no network).
  • If missing, xcodebuild -downloadComponent MetalToolchain triggers Apple's downloader. xcodebuild streams progress output so the user can see what's happening on the multi-GB download.
  • After the download attempt, re-probe xcrun --find metal and fail loudly with manual-install instructions if the tool is still missing. The re-probe is load-bearing: xcodebuild -downloadComponent can exit 0 without actually downloading the component (e.g. when App Store credentials are missing). Without the re-probe the bug just resurfaces later in cargo build.

Placement

Placed between xcodebuild -runFirstLaunch and the brew installs so the Apple-side environment setup happens together. The script structure stays linear and matches the convention ./script/macos/bootstrap already uses (probe → install → continue).

Scope

Test plan

  • On a fresh macOS dev box without Metal Toolchain installed, ./script/bootstrap detects the gap, runs xcodebuild -downloadComponent MetalToolchain, and produces a working xcrun --find metal after the download completes.
  • On a macOS box where Metal Toolchain is already installed, ./script/bootstrap no-ops the new probe (xcrun --find metal succeeds, no xcodebuild invocation).
  • If xcodebuild -downloadComponent exits 0 without installing (e.g. App Store creds missing), the script fails with the manual-install message rather than letting cargo fail later.
  • No regression on the existing xcodebuild -runFirstLaunch step or the brew/rust/gcloud installs that follow.

`crates/warpui/build.rs` invokes the `metal` compiler to translate shader
sources to `.air` at cargo-build time. Xcode 16 split the Metal Toolchain
into a separately-downloadable component that is not installed by Xcode's
default first-launch setup, so a fresh macOS dev box following
`./script/bootstrap` then `./script/run` fails with a confusing
`build.rs` panic deep in the cargo output:

    error compiling metal shaders to .air; error: error: cannot execute
    tool 'metal' due to missing Metal Toolchain;
    use: xcodebuild -downloadComponent MetalToolchain

This is the macOS counterpart to warpdotdev#9544 (Node.js / yarn check on Linux /
Windows, fixed in warpdotdev#9669). Same pattern: detect a missing build-time tool
during bootstrap rather than during cargo build.

Implementation:

- `xcrun --find metal` probes for the toolchain (fast, no network).
- If missing, `xcodebuild -downloadComponent MetalToolchain` triggers
  Apple's downloader. The script streams xcodebuild's progress output so
  the user can see what's happening on the multi-GB download.
- After the download attempt, re-probe `xcrun --find metal` and fail
  loudly with manual-install instructions if the tool is still missing.
  `xcodebuild -downloadComponent` can exit 0 without actually downloading
  the component (e.g. when App Store credentials are missing), so the
  re-probe is load-bearing — without it the bug just manifests in the
  same place later.

Placed between `xcodebuild -runFirstLaunch` and the brew installs so the
Apple-side environment setup happens together. No change to Linux or
Windows bootstrap scripts.
@cla-bot cla-bot Bot added the cla-signed label May 4, 2026
@github-actions github-actions Bot added the external-contributor Indicates that a PR has been opened by someone outside the Warp team. label May 4, 2026
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 4, 2026

@lonexreb

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

oz-for-oss[bot]
oz-for-oss Bot previously requested changes May 4, 2026
Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This PR adds a macOS bootstrap check that downloads Xcode's separately installed Metal Toolchain before cargo reaches the shader build step.

Concerns

  • The new fallback does not run when xcodebuild -downloadComponent MetalToolchain exits non-zero because the bootstrap script has set -e; in that case users still miss the explicit re-probe/manual-install guidance this change is trying to provide.

Found: 0 critical, 1 important, 0 suggestions

Verdict

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread script/macos/bootstrap Outdated
if ! xcrun --find metal >/dev/null 2>&1; then
echo "Metal Toolchain not installed. Running: xcodebuild -downloadComponent MetalToolchain"
echo "(this can take several minutes on first run; xcodebuild streams progress below)"
xcodebuild -downloadComponent MetalToolchain
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ [IMPORTANT] set -e makes the script exit here on any non-zero downloader status, so the re-probe and manual-install instructions below never run; capture/ignore this command's status and let the xcrun --find metal check decide whether bootstrap should fail.

Per oz-for-oss review on PR warpdotdev#10017: the script runs under `set -e`, so
`xcodebuild -downloadComponent MetalToolchain` exiting non-zero would
abort the script before reaching the re-probe and manual-install
instructions. Append `|| true` so the downloader's status is captured
but doesn't trip set -e; the `xcrun --find metal` re-probe below remains
the source of truth on whether the toolchain is now usable.

The re-probe was already load-bearing for the silent-success case (where
xcodebuild exits 0 without actually downloading, e.g. when App Store
credentials are missing). This change extends the same defense to the
explicit-failure case.
@lonexreb
Copy link
Copy Markdown
Contributor Author

lonexreb commented May 4, 2026

/oz-review

@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 4, 2026

@lonexreb

I'm re-reviewing this pull request in response to a review request.

You can view the conversation on Warp.

I reviewed this pull request and requested human review from: @warpdotdev/oss-maintainers.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot dismissed their stale review May 4, 2026 09:34

Oz no longer requests changes for this pull request after the latest automated review.

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This PR updates the macOS bootstrap script to detect a missing Xcode Metal Toolchain before Cargo reaches the warpui shader build, attempts Apple's component download, and re-probes before continuing. The added flow keeps the failure mode in bootstrap with clear manual recovery instructions.

Concerns

  • No blocking concerns found in the changed lines.

Verdict

Found: 0 critical, 0 important, 0 suggestions

Approve

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot requested review from a team and lucieleblanc and removed request for a team May 4, 2026 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed external-contributor Indicates that a PR has been opened by someone outside the Warp team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

./script/bootstrap does not install Xcode Metal Toolchain on macOS, leading to confusing cargo build failure in crates/warpui/build.rs

1 participant