fix(pm2): avoid nvm misdetection of Homebrew keg-only node interpreter - #737
Draft
BoYanZh wants to merge 1 commit into
Draft
fix(pm2): avoid nvm misdetection of Homebrew keg-only node interpreter#737BoYanZh wants to merge 1 commit into
BoYanZh wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pm2 (>=6, lib/Common.js) treats any interpreter path containing the substring
node@as an nvm version handle and runsnvm 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 everybotmux start/restartfails with:The keg-only formula has no
@-free path to hand pm2 (Cellar/, opt/, and a non-default bin/ symlink all containnode@), 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.