From c5daa4f37ac6c38eed2f331dec273bc757d59b75 Mon Sep 17 00:00:00 2001 From: Javis Date: Mon, 9 Mar 2026 18:07:31 +0800 Subject: [PATCH 1/2] fix(install): detect and warn about multiple Node.js environments Add warn_multiple_node_environments() function that detects when users have multiple Node.js version managers installed (nvm, fnm, volta, homebrew, system). When multiple environments are detected, the installer now shows a warning with: - List of detected environments - Currently active node path - Recommendation to use one manager consistently - Tip to verify installation with 'which openclaw' This helps prevent the confusion described in #40839 where users end up with multiple openclaw installations in different node_modules directories. Closes #40839 --- scripts/install.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/scripts/install.sh b/scripts/install.sh index f7f13490796..cf9250d7755 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1385,6 +1385,55 @@ ensure_node22_active_shell() { return 1 } +# Detect multiple Node.js environments and warn users +# This helps prevent confusion when multiple openclaw installations exist +warn_multiple_node_environments() { + local envs_found=() + local active_node="" + active_node="$(command -v node 2>/dev/null || true)" + + # Check for nvm + if [[ -n "${NVM_DIR:-}" ]] || [[ -d "$HOME/.nvm" ]]; then + envs_found+=("nvm (~/.nvm)") + fi + + # Check for fnm + if [[ -n "${FNM_DIR:-}" ]] || [[ -d "$HOME/.local/share/fnm" ]] || [[ -d "$HOME/.fnm" ]] || command -v fnm &>/dev/null; then + envs_found+=("fnm") + fi + + # Check for volta + if [[ -n "${VOLTA_HOME:-}" ]] || [[ -d "$HOME/.volta" ]] || command -v volta &>/dev/null; then + envs_found+=("volta (~/.volta)") + fi + + # Check for Homebrew node (macOS) + if [[ -x "/opt/homebrew/bin/node" ]] || [[ -x "/usr/local/bin/node" ]]; then + if [[ "$active_node" != "/opt/homebrew/bin/node" && "$active_node" != "/usr/local/bin/node" ]]; then + envs_found+=("homebrew") + fi + fi + + # Check for system node + if [[ -x "/usr/bin/node" ]]; then + if [[ "$active_node" != "/usr/bin/node" ]]; then + envs_found+=("system (/usr/bin/node)") + fi + fi + + # Warn if multiple environments detected + if [[ ${#envs_found[@]} -gt 1 ]]; then + ui_warn "Multiple Node.js environments detected: ${envs_found[*]}" + echo "" + echo " ${INFO}This can cause confusion if openclaw is installed in different locations.${NC}" + echo " ${INFO}Current active node: ${active_node:-none}${NC}" + echo "" + echo " ${MUTED}Recommendation: Use one Node version manager consistently.${NC}" + echo " ${MUTED}After installing, verify with: which openclaw${NC}" + echo "" + fi +} + check_node() { if command -v node &> /dev/null; then NODE_VERSION="$(node_major_version || true)" @@ -2260,6 +2309,9 @@ main() { ui_stage "Preparing environment" + # Warn about multiple Node environments + warn_multiple_node_environments + # Step 1: Homebrew (macOS only) install_homebrew From d984a5f572c4c2467f847ef7ca1eff5fb72eb7a6 Mon Sep 17 00:00:00 2001 From: Javis Date: Mon, 9 Mar 2026 19:28:34 +0800 Subject: [PATCH 2/2] fix: address review feedback for multi-node detection - Add -e flag to echo commands to properly render ANSI color codes - Remove asymmetric detection logic: now count ALL installed environments regardless of which one is currently active (fixes the common macOS scenario where homebrew is active + nvm is installed) Co-authored-by: greptile-apps --- scripts/install.sh | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index cf9250d7755..85c22d2ab88 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1392,44 +1392,40 @@ warn_multiple_node_environments() { local active_node="" active_node="$(command -v node 2>/dev/null || true)" - # Check for nvm + # Check for nvm (always count if installed, regardless of active node) if [[ -n "${NVM_DIR:-}" ]] || [[ -d "$HOME/.nvm" ]]; then envs_found+=("nvm (~/.nvm)") fi - # Check for fnm + # Check for fnm (always count if installed) if [[ -n "${FNM_DIR:-}" ]] || [[ -d "$HOME/.local/share/fnm" ]] || [[ -d "$HOME/.fnm" ]] || command -v fnm &>/dev/null; then envs_found+=("fnm") fi - # Check for volta + # Check for volta (always count if installed) if [[ -n "${VOLTA_HOME:-}" ]] || [[ -d "$HOME/.volta" ]] || command -v volta &>/dev/null; then envs_found+=("volta (~/.volta)") fi - # Check for Homebrew node (macOS) + # Check for Homebrew node (macOS) - always count if exists if [[ -x "/opt/homebrew/bin/node" ]] || [[ -x "/usr/local/bin/node" ]]; then - if [[ "$active_node" != "/opt/homebrew/bin/node" && "$active_node" != "/usr/local/bin/node" ]]; then - envs_found+=("homebrew") - fi + envs_found+=("homebrew") fi - # Check for system node + # Check for system node - always count if exists if [[ -x "/usr/bin/node" ]]; then - if [[ "$active_node" != "/usr/bin/node" ]]; then - envs_found+=("system (/usr/bin/node)") - fi + envs_found+=("system (/usr/bin/node)") fi # Warn if multiple environments detected if [[ ${#envs_found[@]} -gt 1 ]]; then ui_warn "Multiple Node.js environments detected: ${envs_found[*]}" echo "" - echo " ${INFO}This can cause confusion if openclaw is installed in different locations.${NC}" - echo " ${INFO}Current active node: ${active_node:-none}${NC}" + echo -e " ${INFO}This can cause confusion if openclaw is installed in different locations.${NC}" + echo -e " ${INFO}Current active node: ${active_node:-none}${NC}" echo "" - echo " ${MUTED}Recommendation: Use one Node version manager consistently.${NC}" - echo " ${MUTED}After installing, verify with: which openclaw${NC}" + echo -e " ${MUTED}Recommendation: Use one Node version manager consistently.${NC}" + echo -e " ${MUTED}After installing, verify with: which openclaw${NC}" echo "" fi }