Dual Install: Shadowed openclaw Binary — Wrong Version Runs
// You upgraded OpenClaw but `openclaw --version` still shows an old build, doctor fixes never stick, or gateway behavior matches a release you thought you removed. This almost always means two global installs exist — commonly `sudo npm i -g openclaw` under /usr/local/bin plus a user-level install under ~/.npm-global or nvm — and your shell resolves the wrong one first. The shadowed binary is silent: commands succeed, but they run stale code. This unofficial guide shows how to map every copy on disk, pick one install strategy, fix PATH precedence, and reinstall cleanly to the user prefix OpenClaw docs recommend.
🔍 Is This Your Issue?
✅ Fix 1 — Map Every openclaw Binary on Disk
# List every openclaw on PATH which -a openclaw # Bash: show all resolved names type -a openclaw # Compare versions at each path /usr/local/bin/openclaw --version 2>/dev/null ~/.npm-global/bin/openclaw --version 2>/dev/null # Show npm global roots npm prefix -g sudo npm prefix -g 2>/dev/null
# Check both npm global trees npm list -g openclaw --depth=0 sudo npm list -g openclaw --depth=0 2>/dev/null # See what your shell actually runs hash -r # bash: clear command cache command -v openclaw openclaw --version
✅ Fix 2 — Remove the Duplicate Install Path
# Remove user-level global copy npm uninstall -g openclaw # Remove system-wide sudo copy (if present) sudo npm uninstall -g openclaw # Verify nothing left on PATH which -a openclaw || echo "no openclaw on PATH — good"
# Optional: delete stale symlinks manually sudo rm -f /usr/local/bin/openclaw rm -f ~/.npm-global/bin/openclaw # Clear shell hash table hash -r # Confirm clean slate which -a openclaw
✅ Fix 3 — Fix PATH Order & Reinstall to User Prefix
# Standard user prefix (recommended) npm config set prefix "$HOME/.npm-global" mkdir -p "$HOME/.npm-global/bin" # Add to ~/.bashrc or ~/.zshrc — npm bin FIRST export PATH="$HOME/.npm-global/bin:$PATH" # Reload shell source ~/.bashrc # or ~/.zshrc
# Fresh install to user prefix npm i -g openclaw@latest # Verify single binary which -a openclaw openclaw --version openclaw doctor # Restart gateway if running openclaw gateway restart
Pick either user-level npm global (recommended) OR system-wide sudo install — never both. After cleanup, `which -a openclaw` should return exactly one path. Pin your npm prefix in ~/.npmrc so future `npm i -g` never lands in a second location.
- • Never mix `sudo npm i -g openclaw` with a user-level global install — choose one prefix and stick to it
- • After any install, run `which -a openclaw` and `openclaw --version` before restarting gateway or running doctor
- • Put your npm global bin (from `npm prefix -g`/bin) ahead of /usr/local/bin in ~/.bashrc or ~/.zshrc
- • If you use nvm/fnm, ensure the version manager init runs in non-interactive shells (systemd, cron, SSH)
- • Document your chosen install path in a README on the host so future-you does not sudo-install again