fix(installer): source nvm before Node detection (#49556)#49594
fix(installer): source nvm before Node detection (#49556)#49594eliot-onbox wants to merge 1 commit intoopenclaw:mainfrom
Conversation
When the installer runs via curl|bash, .bashrc/.zshrc are not sourced. This means nvm's PATH modifications are missing and the system Node (e.g. v8) is found instead of the nvm-managed version (e.g. v22). Fix: source nvm.sh before check_node() so nvm-managed Node versions appear on PATH. Respects NVM_DIR if set, falls back to ~/.nvm. Fixes openclaw#49556
Greptile SummaryThis PR fixes a real and well-understood problem: when the installer is piped through Changes
Minor issue found
Confidence Score: 4/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: scripts/install.sh
Line: 2350
Comment:
**Stdout from nvm.sh not suppressed**
`2>/dev/null` only redirects stderr. When `nvm.sh` is sourced it can print to stdout — for example, if a `.nvmrc` or default alias is set, nvm may emit `"Now using node v22.x.x"` on stdout. This would appear unexpectedly in the middle of the installer's own formatted output.
The PR description says _"Suppresses any nvm output with `2>/dev/null`"_, but that claim only holds for stderr. Use `&>/dev/null` (bash-specific, already used elsewhere in this script) to redirect both streams:
```suggestion
. "${NVM_DIR}/nvm.sh" &>/dev/null || true
```
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: "fix(installer): sour..." |
| export NVM_DIR="${HOME}/.nvm" | ||
| fi | ||
| if [[ -n "${NVM_DIR:-}" && -s "${NVM_DIR}/nvm.sh" ]]; then | ||
| . "${NVM_DIR}/nvm.sh" 2>/dev/null || true |
There was a problem hiding this comment.
Stdout from nvm.sh not suppressed
2>/dev/null only redirects stderr. When nvm.sh is sourced it can print to stdout — for example, if a .nvmrc or default alias is set, nvm may emit "Now using node v22.x.x" on stdout. This would appear unexpectedly in the middle of the installer's own formatted output.
The PR description says "Suppresses any nvm output with 2>/dev/null", but that claim only holds for stderr. Use &>/dev/null (bash-specific, already used elsewhere in this script) to redirect both streams:
| . "${NVM_DIR}/nvm.sh" 2>/dev/null || true | |
| . "${NVM_DIR}/nvm.sh" &>/dev/null || true |
Prompt To Fix With AI
This is a comment left during a code review.
Path: scripts/install.sh
Line: 2350
Comment:
**Stdout from nvm.sh not suppressed**
`2>/dev/null` only redirects stderr. When `nvm.sh` is sourced it can print to stdout — for example, if a `.nvmrc` or default alias is set, nvm may emit `"Now using node v22.x.x"` on stdout. This would appear unexpectedly in the middle of the installer's own formatted output.
The PR description says _"Suppresses any nvm output with `2>/dev/null`"_, but that claim only holds for stderr. Use `&>/dev/null` (bash-specific, already used elsewhere in this script) to redirect both streams:
```suggestion
. "${NVM_DIR}/nvm.sh" &>/dev/null || true
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 631caec633
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| export NVM_DIR="${HOME}/.nvm" | ||
| fi | ||
| if [[ -n "${NVM_DIR:-}" && -s "${NVM_DIR}/nvm.sh" ]]; then | ||
| . "${NVM_DIR}/nvm.sh" 2>/dev/null || true |
There was a problem hiding this comment.
Sourcing nvm.sh directly here can change the active Node version before check_node() runs, because nvm.sh defaults to nvm_process_parameters auto mode use and will switch from a system Node to the default nvm alias. In environments where PATH already has a valid system Node (e.g. v24) but nvm default is older (e.g. v18), this makes the installer mis-detect Node as unsupported, trigger unnecessary installation, and potentially fail on hosts without sudo. Load nvm with --no-use (or equivalent) so we detect availability without mutating the active runtime.
Useful? React with 👍 / 👎.
Problem
When the installer runs via
curl -fsSL https://openclaw.ai/install.sh | bash, shell profile files (.bashrc,.zshrc) are not sourced. This means nvm's PATH modifications are missing andcommand -v nodefinds the system Node (e.g. v8 at/usr/local/bin/node) instead of the nvm-managed version (e.g. v22 at~/.nvm/versions/node/v22.x/bin/node).The installer then unnecessarily tries to install/upgrade Node, or errors out telling the user to fix their PATH manually.
Fix
Source
nvm.shbeforecheck_node()is called, so nvm-managed Node versions appear on PATH:NVM_DIRif already set~/.nvm(the default nvm install location)2>/dev/null|| true)Scope
This PR only addresses nvm. Other version managers (fnm, volta, asdf, mise) are not handled — that could be a follow-up if needed.
Fixes #49556