fix(desktop): run.sh fails when Node is installed via Homebrew — fall back to official Node (#7802)#7812
Conversation
…t self-contained (#7802) prepare-agent-runtime.sh --local-node copies the developer's node binary into Desktop/Sources/Resources/node, but Homebrew's node is a thin stub dynamically linked to libnode.X.dylib via @rpath, so the copied binary aborts with dyld 'Library not loaded' at startup. Validate that the staged copy can actually run; when it can't, fall back to the existing checksum-verified official Node download (stage_universal_node). Static builds (official tarballs, nvm) stage locally exactly as before. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Greptile SummaryFixes a crash for developers with Homebrew-installed Node.js by adding a post-copy exec check in
Confidence Score: 5/5Safe to merge; the change is a small, well-scoped fallback in a developer build script with no production or data-path impact. The diff is minimal: a post-copy exec check replaces a bare --version call that previously let a Homebrew stub crash the entire script. The fallback correctly deletes the bad copy and delegates to the existing, checksum-verified download path. The if ! idiom is correct with set -euo pipefail, 2>/dev/null appropriately suppresses the dyld crash output in a non-interactive script, and validate_runtime_tree at the end provides an independent end-to-end sanity check of whatever binary was staged. No logic errors or regressions are introduced. No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "fix(desktop): fall back to official Node..." | Re-trigger Greptile |
Bug
#7802 —
./run.shaborts during[Preparing agent runtime...]for any developer whosenodecomes from Homebrew (v22+):Root cause
scripts/prepare-agent-runtime.sh --local-node(always invoked byrun.sh) stages the developer'snodebinary by copying it intoDesktop/Sources/Resources/node. Homebrew's node is a thin stub dynamically linked tolibnode.X.dylibvia@rpath/@loader_path, so the copy aborts the moment it runs outside its install prefix. Official nodejs.org tarballs are statically linked and unaffected.Fix
After staging the local binary, run
$NODE_RESOURCE --versionto verify the copy is actually self-contained. If it can't run, delete it and fall back to the script's existing checksum-verified official-Node download path (stage_universal_node). Static builds stage locally exactly as before — no behavior change for them.An exec-check (rather than
otool -Lsniffing) also catches any other future linkage/arch problem with a staged local binary.Verification
Reproduced and verified on a machine with Homebrew node v26 (
@rpath/libnode.147.dylib):Desktop/Sources/Resources/node --version→v22.14.0.PATH, the script stages it locally with no download, as before.(Ran with
--skip-npmin a fresh worktree, so the later unrelatedagent/distvalidation failed as expected; the staging logic under change was exercised end-to-end.)Fixes #7802
🤖 automated by hourly watchdog; opened for review, not merged.
🤖 Generated with Claude Code