← Back to PRs

#20584: fix: use stable Homebrew symlink for daemon node path

by mwfj open 2026-02-19 03:37 View on GitHub →
gateway size: S
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