Repository navigation
fix(apps): Apple app builds fail when a Node version-manager shim leads PATH - #168139
Conversation
…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.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesResolve 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible 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 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe 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]
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +78, Tests +112, Docs +4, Config 0. Total +194 across 4 files. Added test files: 1. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed October 9, 2026, 11:17 PM ET / October 10, 2026, 03:17 UTC (Revision 2). |
|
Landing note: the remaining red checks on head
Follow-ups for both |
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…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.
What Problem This Solves
Fixes: macOS and iOS app builds, including
scripts/package-mac-app.sh, abort withmise ERROR No version is set for shim: nodewhen a Node version-manager shim directory (mise, asdf, Volta) comes first onPATH.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:$PATHworkaround. 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, defaultPATH). TheGenerateGatewayProtocolplugin handed that command the firstnodeonPATH, 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 (
PATHentries, then/opt/homebrew/bin/node,/usr/local/bin/node), from the repository root, to report its realprocess.execPathand version, and gives the prebuild the first concrete binary thatnode-version.mjsaccepts (>=24.16.0 <25 || >=26.1.0). The engine range stays owned bynode-version.mjsinstead 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
main(6f32dc60dae9) on the Mac where the release build failed.swift build --package-path apps/shared/OpenClawKit --target OpenClawProtocolwith the mise shim first onPATHfails: SwiftPM logsexecutable: …/mise/shims/node … environment: [], thenmise ERROR No version is set for shim: node.BUILD_CONFIG=debug SIGN_IDENTITY=- ALLOW_ADHOC_SIGNING=1 scripts/package-mac-app.shcompletes with mise shims still first onPATH(✅ Bundle ready at …/dist/OpenClaw.app;codesign --verify --deep --strictpasses; protocol models generated during the run).plugin.swift(too-old Node and an environment-dependent shim leadingPATH,NODE_OPTIONS=--input-type=module) builds and generates with the concrete Homebrew Node under SwiftPM's native build system, Swift Build, andxcodebuildfor an iOS Simulator destination.sleep 600 & exit 0and 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.test/scripts/generate-gateway-protocol-plugin.test.tsbuilds the fixture with the realplugin.swiftunder SwiftPM. It fails against the original plugin, which selected the too-old Node, and against the intermediate version withoutNODE_OPTIONSisolation; it passes now. It is Darwin-only and added totest: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 realswift build, because only SwiftPM can prove the empty prebuild environment.pnpm test:macos:ci:2passed locally (12 files, 498 tests, 62 s). macOS lanes (macos-node,macos-swift) do not run on ordinary pull requests (runMacosrequires a non-PR event inscripts/ci-build-manifest.mjs), so this test first runs in CI on a fullmainvalidation 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 (unboundedspawnSyncin the test, inheritedNODE_OPTIONS, unbounded probe reads).3274f57e6acb): every lane that ran passed (macOS lanes are not scheduled for pull requests). The only failures were inherited frommain: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 baselinef18b305771d7) with the aggregateopenclaw/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 onmainby 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.