Skip to content

fix(desktop): run.sh fails when Node is installed via Homebrew — fall back to official Node (#7802)#7812

Merged
kodjima33 merged 1 commit into
mainfrom
watchdog/issue-7802-homebrew-node-fallback
Jun 11, 2026
Merged

fix(desktop): run.sh fails when Node is installed via Homebrew — fall back to official Node (#7802)#7812
kodjima33 merged 1 commit into
mainfrom
watchdog/issue-7802-homebrew-node-fallback

Conversation

@kodjima33

Copy link
Copy Markdown
Collaborator

Bug

#7802./run.sh aborts during [Preparing agent runtime...] for any developer whose node comes from Homebrew (v22+):

dyld[4902]: Library not loaded: @rpath/libnode.147.dylib
  Referenced from: .../Desktop/Sources/Resources/node
Abort trap: 6

Root cause

scripts/prepare-agent-runtime.sh --local-node (always invoked by run.sh) stages the developer's node binary by copying it into Desktop/Sources/Resources/node. Homebrew's node is a thin stub dynamically linked to libnode.X.dylib via @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 --version to 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 -L sniffing) 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):

  • Before: copied stub aborts with the exact dyld error from the issue (exit 134).
  • After: script logs the fallback, downloads checksummed Node v22.14.0, stages a universal binary; Desktop/Sources/Resources/node --versionv22.14.0.
  • Happy path: with a self-contained node first in PATH, the script stages it locally with no download, as before.

(Ran with --skip-npm in a fresh worktree, so the later unrelated agent/dist validation 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

…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-apps

greptile-apps Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Fixes a crash for developers with Homebrew-installed Node.js by adding a post-copy exec check in stage_local_node: if the staged binary can't run standalone (e.g., because it's a Homebrew stub linked to libnode.dylib via @rpath), it is removed and the existing checksum-verified official Node download path is used as a fallback.

  • Adds an exec-check ($NODE_RESOURCE --version 2>/dev/null) immediately after staging the local binary, falling back to stage_universal_node on any failure — this catches dynamic-linkage issues, arch mismatches, and similar problems generically rather than relying on otool -L inspection.
  • No behavior change for developers with a self-contained (static) Node binary; the happy path is identical to before.

Confidence Score: 5/5

Safe 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

Filename Overview
desktop/scripts/prepare-agent-runtime.sh Adds a post-copy exec check in stage_local_node with a clean fallback to stage_universal_node; logic is correct, handles set -e properly, and cleans up the failed copy before delegating.

Reviews (1): Last reviewed commit: "fix(desktop): fall back to official Node..." | Re-trigger Greptile

@kodjima33 kodjima33 merged commit cd312c0 into main Jun 11, 2026
3 checks passed
@kodjima33 kodjima33 deleted the watchdog/issue-7802-homebrew-node-fallback branch June 11, 2026 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

run.sh fails to launch on macOS when Node is installed via Homebrew

1 participant