Skip to content

fix(pm2): avoid nvm misdetection of Homebrew keg-only node interpreter - #737

Draft
BoYanZh wants to merge 1 commit into
deepcoldy:masterfrom
BoYanZh:fix/pm2-homebrew-node-at-interpreter
Draft

fix(pm2): avoid nvm misdetection of Homebrew keg-only node interpreter#737
BoYanZh wants to merge 1 commit into
deepcoldy:masterfrom
BoYanZh:fix/pm2-homebrew-node-at-interpreter

Conversation

@BoYanZh

@BoYanZh BoYanZh commented Aug 4, 2026

Copy link
Copy Markdown

pm2 (>=6, lib/Common.js) treats any interpreter path containing the substring node@ as an nvm version handle and runs nvm install <suffix>. When botmux is installed under a Homebrew keg-only Node, process.execPath is e.g. /home/linuxbrew/.linuxbrew/Cellar/node@22/22.23.1/bin/node, so pm2 misreads it as version "22/22.23.1/bin/node" and every botmux start/ restart fails with:

[PM2] Installing Node v22/22.23.1/bin/node
Version '22/22.23.1/bin/node' not found

The keg-only formula has no @-free path to hand pm2 (Cellar/, opt/, and a non-default bin/ symlink all contain node@), so instead of pointing at a different binary we materialize a stable @-free symlink under ~/.botmux (node-interpreter) that resolves to the exact same Node, and pass that as the pm2 interpreter. The symlink is refreshed when execPath changes (e.g. a Homebrew patch bump) and we fall back to the raw execPath on any fs error. Non-Homebrew installs are unaffected — execPath is returned verbatim.

pm2 (>=6, lib/Common.js) treats any interpreter path containing the
substring `node@` as an nvm version handle and runs `nvm install <suffix>`.
When botmux is installed under a Homebrew keg-only Node, process.execPath is
e.g. /home/linuxbrew/.linuxbrew/Cellar/node@22/22.23.1/bin/node, so pm2
misreads it as version "22/22.23.1/bin/node" and every `botmux start`/
`restart` fails with:

    [PM2] Installing Node v22/22.23.1/bin/node
    Version '22/22.23.1/bin/node' not found

The keg-only formula has no `@`-free path to hand pm2 (Cellar/, opt/, and a
non-default bin/ symlink all contain `node@`), so instead of pointing at a
different binary we materialize a stable `@`-free symlink under ~/.botmux
(node-interpreter) that resolves to the exact same Node, and pass that as the
pm2 interpreter. The symlink is refreshed when execPath changes (e.g. a
Homebrew patch bump) and we fall back to the raw execPath on any fs error.
Non-Homebrew installs are unaffected — execPath is returned verbatim.

Co-authored-by: TRAE CLI <noreply@bytedance.com>
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.

1 participant