Skip to content

fix(apps): Apple app builds fail when a Node version-manager shim leads PATH - #168139

Merged
steipete merged 1 commit into
mainfrom
steipete/gifted-volhard-5a9ba3
Oct 10, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/gifted-volhard-5a9ba3

Conversation

@steipete

@steipete steipete commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: macOS and iOS app builds, including scripts/package-mac-app.sh, abort with mise ERROR No version is set for shim: node when a Node version-manager shim directory (mise, asdf, Volta) comes first on PATH.

User Impact

Developers and release operators can build the Apple apps from a shell with mise, asdf, or Volta activated, without the PATH=/opt/homebrew/opt/node@24/bin:$PATH workaround. Builds also stop picking a Node outside the repository's engine range. When no supported Node exists, the error names what was found and what OpenClaw requires; with no Node at all, the error text is unchanged.

Why This Change Was Made

SwiftPM runs build-tool prebuild commands with an empty environment (no HOME, default PATH). The GenerateGatewayProtocol plugin handed that command the first node on PATH, which in a mise-activated shell is the mise shim; without the caller's environment the shim cannot find its configuration and fails.

The plugin process itself still has the caller's environment, so it now asks each candidate (PATH entries, then /opt/homebrew/bin/node, /usr/local/bin/node), from the repository root, to report its real process.execPath and version, and gives the prebuild the first concrete binary that node-version.mjs accepts (>=24.16.0 <25 || >=26.1.0). The engine range stays owned by node-version.mjs instead of being copied into Swift. Plain Node installs keep their existing path; only launchers are replaced by the binary they start.

The probe is bounded so a bad candidate cannot hang build planning: it drops inherited NODE_OPTIONS (the real prebuild never sees them), waits at most 30 seconds per candidate, and reads stdout without blocking, so a stalled launcher or one that leaves a descendant holding stdout open is skipped and the next candidate is tried. Under SwiftPM's default plugin sandbox the best-effort kill of a stalled launcher is refused, so such a launcher is abandoned rather than killed; planning still continues.

Evidence

  • Reproduced on unmodified main (6f32dc60dae9) on the Mac where the release build failed. swift build --package-path apps/shared/OpenClawKit --target OpenClawProtocol with the mise shim first on PATH fails: SwiftPM logs executable: …/mise/shims/node … environment: [], then mise ERROR No version is set for shim: node.
  • End-to-end: with this change, BUILD_CONFIG=debug SIGN_IDENTITY=- ALLOW_ADHOC_SIGNING=1 scripts/package-mac-app.sh completes with mise shims still first on PATH (✅ Bundle ready at …/dist/OpenClaw.app; codesign --verify --deep --strict passes; protocol models generated during the run).
  • All plugin hosts: a fixture package around the final plugin.swift (too-old Node and an environment-dependent shim leading PATH, NODE_OPTIONS=--input-type=module) builds and generates with the concrete Homebrew Node under SwiftPM's native build system, Swift Build, and xcodebuild for an iOS Simulator destination.
  • Bounded probe: with a launcher that runs sleep 600 & exit 0 and a launcher that never exits ahead of the working shim, the build succeeds in about 42 s (the stalled candidate costs its 30 s deadline). With no Node at all, the original error text is unchanged; with only unsupported or unrunnable candidates, the error lists them.
  • Regression: new test/scripts/generate-gateway-protocol-plugin.test.ts builds the fixture with the real plugin.swift under SwiftPM. It fails against the original plugin, which selected the too-old Node, and against the intermediate version without NODE_OPTIONS isolation; it passes now. It is Darwin-only and added to test:macos:ci:2. pnpm test test/scripts/generate-gateway-protocol-plugin.test.ts --maxWorkers=1: 5–9 s test time (about 10–12 s wall), all in one real swift build, because only SwiftPM can prove the empty prebuild environment. pnpm test:macos:ci:2 passed locally (12 files, 498 tests, 62 s). macOS lanes (macos-node, macos-swift) do not run on ordinary pull requests (runMacos requires a non-PR event in scripts/ci-build-manifest.mjs), so this test first runs in CI on a full main validation run; no PR CI seconds exist for it.
  • pnpm tsgo:test:root, oxlint, oxfmt, SwiftFormat, and SwiftLint pass on the changed files. Codex autoreview at P2 is clean after fixing three findings (unbounded spawnSync in the test, inherited NODE_OPTIONS, unbounded probe reads).
  • PR CI (run 38019817542, head 3274f57e6acb): every lane that ran passed (macOS lanes are not scheduled for pull requests). The only failures were inherited from main: checks-node-changed-extensions-bundle-29 (extensions/whatsapp/src/send.delivery-recovery.test.ts › "preserves long styles and quotes only the first chunk", reproduced without this PR at the tested merge baseline f18b305771d7) with the aggregate openclaw/ci-gate, plus the non-required OpenClawKit Periphery scan from fix(apple): Gateway connection stays dead for up to two minutes after a network change #168024 (since fixed on main by fix(apple): Shared OpenClawKit Periphery fails on every OpenClawKit PR #168171). Landed through the native pre-existing-failure admin exception; ClawSweeper review on the exact head: ready, no findings.

…lugin

SwiftPM runs build-tool prebuild commands with an empty environment, so
the GenerateGatewayProtocol plugin's first-on-PATH node, a mise/asdf/Volta
shim in activated shells, failed with "No version is set for shim: node"
and aborted scripts/package-mac-app.sh.

The plugin now probes each candidate from the repository root with the
caller's environment (minus NODE_OPTIONS), asks it for its real
process.execPath and version, and hands the prebuild the first concrete
binary that node-version.mjs accepts. Probes are bounded (30 s deadline,
non-blocking stdout read) so stalled launchers cannot hang planning.
Errors name unsupported or unrunnable candidates; with no Node at all the
original message is unchanged.

Adds a Darwin-only SwiftPM fixture regression to test:macos:ci:2 and
documents the selection in the macOS dev setup guide.
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: macos App: macos size: M labels Oct 10, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 10, 2026
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Resolve Node version-manager shims to supported concrete binaries before generating Apple protocol models.

Example: Package OpenClaw.app with mise shims first on PATH and supported Homebrew Node installed.

  • Before: SwiftPM protocol generation aborts with “No version is set for shim: node”.
  • After: The plugin resolves the supported Node binary and app packaging completes.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, focused repair with supplied production packaging evidence and meaningful SwiftPM regression coverage; no actionable finding remains.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): Supplied terminal observations exercise the changed plugin through real macOS packaging with mise shims first on PATH and show successful bundle generation; additional host and stalled-launcher runs cover the resolution and timeout behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Apple app builds fail when SwiftPM hands an environment-dependent Node shim to its empty-environment prebuild.
Reason: The focused repair restores the existing automatic-generation contract without adding configuration or changing the supported Node policy.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current Apple build failure at the owning SwiftPM plugin; no actionable correctness or security defect was found, and the earlier draft blocker is resolved.

Priority: P2
Reviewed head: 3274f57e6acbe762638386738a89e14918b56950

Before merge

None.

Findings

None.

Agent review details

How this fits together

The SwiftPM build-tool plugin selects a build-time Node executable and invokes the canonical protocol generator, producing Swift models consumed by Apple app builds.

flowchart LR
  A[Apple app build] --> B[SwiftPM plugin]
  B --> C[Probe Node candidates]
  C --> D[Canonical version policy]
  C --> E[Concrete Node binary]
  E --> F[Protocol generator]
  F --> G[Generated Swift models]
Loading

Technical review

Best possible solution:

Land the focused plugin repair after the normal exact-head CI gates pass.

Do we have a high-confidence way to reproduce the issue?

Current-main source retains the launcher-selection mechanism, and supplied SwiftPM output shows its failure on the affected Mac; this read-only review executed no target code.

Is this the best way to solve the issue?

Resolving launchers before the empty-environment prebuild addresses the cause while preserving the existing generator and supported-version owners.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 3dac10b95866.

Provenance checked

  • SwiftPM Node selection keeps the original intent (d6e4bd4: Generate native protocol models automatically in ignored build outputs while keeping canonical schemas and generators authoritative.)
  • macOS CI regression routing keeps the original intent (d22146e: Partition macOS tests and admit long jobs first; this patch retains the partition and adds its platform-specific regression.)
  • macOS developer prerequisites keeps the original intent (ce0e84d: Document supported Node release floors needed for lossless SQLite reads; the addition explains selection without changing those floors.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +78, Tests +112, Docs +4, Config 0. Total +194 across 4 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 88 10 +78
Tests 1 112 0 +112
Docs 1 4 0 +4
Config 1 1 1 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 205 11 +194

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +88/-10 lines; tests +112/-0 lines Production growth implements launcher resolution and bounded probing; one SwiftPM fixture protects the empty-environment boundary that direct generator tests bypass.

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Activated version-manager shims break developer and release-operator Apple builds, with an available PATH workaround.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-10T03:12:32.686Z sha 3274f57 :: needs changes before merge. :: none

Reviewed October 9, 2026, 11:17 PM ET / October 10, 2026, 03:17 UTC (Revision 2).

@steipete
steipete marked this pull request as ready for review October 10, 2026 03:13
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 10, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Landing note: the remaining red checks on head 3274f57e6acb are inherited from main and unrelated to this change, so this lands through the native pre-existing-failure admin exception.

  • checks-node-changed-extensions-bundle-29 (CI run 38019817542, attempt 1) and the aggregate openclaw/ci-gate: extensions/whatsapp/src/send.delivery-recovery.test.ts › "WhatsApp delivery recovery › preserves long styles and quotes only the first chunk" receives 3 chunks instead of 5. It fails identically without this PR on main at 6f32dc60dae9 and 5033097b75dd, which bracket the tested merge baseline f18b305771d7. This PR touches only the Swift build plugin, a macOS-only script test, one test:macos:ci:2 script string, and docs; none of it is in that suite's import closure. The suite ran only because the package.json edit widened changed-test selection.
  • Intersect shared OpenClawKit dead code (Shared OpenClawKit Periphery, not part of openclaw/ci-gate): flags _test_setReconnectBackoffMs(_:) and _test_reconnectBackoffMs() in GatewayChannel+Testing.swift, added by fix(apple): Gateway connection stays dead for up to two minutes after a network change #168024, which merged with the same failure. This PR does not touch those files.

Follow-ups for both main issues are being tracked separately.

@steipete
steipete merged commit 3b86cb9 into main Oct 10, 2026
285 of 290 checks passed
@steipete
steipete deleted the steipete/gifted-volhard-5a9ba3 branch October 10, 2026 05:41
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 11, 2026
…lugin (openclaw#168139)

SwiftPM runs build-tool prebuild commands with an empty environment, so
the GenerateGatewayProtocol plugin's first-on-PATH node, a mise/asdf/Volta
shim in activated shells, failed with "No version is set for shim: node"
and aborted scripts/package-mac-app.sh.

The plugin now probes each candidate from the repository root with the
caller's environment (minus NODE_OPTIONS), asks it for its real
process.execPath and version, and hands the prebuild the first concrete
binary that node-version.mjs accepts. Probes are bounded (30 s deadline,
non-blocking stdout read) so stalled launchers cannot hang planning.
Errors name unsupported or unrunnable candidates; with no Node at all the
original message is unchanged.

Adds a Darwin-only SwiftPM fixture regression to test:macos:ci:2 and
documents the selection in the macOS dev setup guide.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: macos App: macos docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant