#20584: fix: use stable Homebrew symlink for daemon node path
gateway
size: S
Cluster:
Node and macOS Enhancements
Fixes #20583 (part 1)
## Problem
`resolvePreferredNodePath()` uses `process.execPath` which returns the realpath (resolved symlink). On Homebrew, this resolves to a versioned Cellar path:
```
/home/linuxbrew/.linuxbrew/Cellar/node/25.6.1/bin/node
```
This is baked into the systemd `ExecStart=` directive. When Homebrew upgrades Node, the old Cellar directory is removed and the daemon fails with exit code 203/EXEC.
## Fix
Added `resolveStableHomebrewPath()` that detects Cellar paths and resolves them to the stable Homebrew symlink (`<prefix>/bin/node`). Covers:
- Linux: `/home/linuxbrew/.linuxbrew/Cellar/node/<ver>/bin/node` → `/home/linuxbrew/.linuxbrew/bin/node`
- macOS ARM: `/opt/homebrew/Cellar/node/<ver>/bin/node` → `/opt/homebrew/bin/node`
- macOS Intel: `/usr/local/Cellar/node/<ver>/bin/node` → `/usr/local/bin/node`
Falls back to the original path if the stable symlink does not exist.
## Tests
5 new tests added to `runtime-paths.test.ts`. All 13 tests pass.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Converts Homebrew Cellar paths to stable symlinks to prevent daemon failures after Node upgrades. The implementation correctly detects versioned Cellar paths and resolves them to stable `/bin/node` symlinks, falling back to the original path when the symlink doesn't exist. All three Homebrew installation locations are covered (Linux, macOS ARM, macOS Intel), and comprehensive tests validate the behavior.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The change is well-isolated, thoroughly tested with 5 new unit tests covering all edge cases, and includes proper fallback behavior. The regex pattern correctly matches all Homebrew Cellar path formats, and the implementation gracefully handles missing symlinks by falling back to the original path.
- No files require special attention
<sub>Last reviewed commit: 2c28dd5</sub>
<!-- greptile_other_comments_section -->
<sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#18112: fix(daemon): gateway install on macOS ignores fnm/nvm node (#18090)
by yinghaosang · 2026-02-16
81.7%
#15475: fix(update): Handle Homebrew+Node Cellar path mismatch
by brandonwise · 2026-02-13
79.7%
#17929: fix(skills): augment PATH with /etc/paths on macOS for binary detec...
by lailoo · 2026-02-16
77.4%
#6064: fix(daemon): prefer bundled node from install-cli.sh over system node
by joyshmitz · 2026-02-01
77.2%
#22370: fix(skills): resolve Homebrew/common binary locations
by AIflow-Labs · 2026-02-21
73.2%
#4709: fix(daemon): include user bin dirs in macOS LaunchAgent PATH
by ekson73 · 2026-01-30
72.8%
#22910: fix(browser): resolve symlinks in upload path validation
by erdinccurebal · 2026-02-21
72.8%
#17951: fix: macOS app: Skill binary detection does not respect /etc/paths ...
by MisterGuy420 · 2026-02-16
72.5%
#23673: docs(imessage): update cliPath to Homebrew path for Apple Silicon
by camerony · 2026-02-22
72.4%
#12804: fix(daemon): use wrapper script for pnpm global installs in service...
by odinho · 2026-02-09
72.4%