Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,18 @@ is_installer_managed_nemoclaw_shim() {
}

remove_nemoclaw_cli() {
# Source nvm if available (curl|bash runs non-interactive, nvm not auto-loaded)
if [ -z "$(command -v npm 2>/dev/null)" ]; then
for nvm_script in "$HOME/.nvm/nvm.sh" "${NVM_DIR:-}/nvm.sh"; do
if [ -f "$nvm_script" ]; then
. "$nvm_script" --no-use 2>/dev/null
# Activate the default or current nvm alias so npm is on PATH
nvm use default >/dev/null 2>&1 || nvm use current >/dev/null 2>&1 || true
break
fi
done
fi

if command -v npm >/dev/null 2>&1; then
npm unlink -g nemoclaw >/dev/null 2>&1 || true
if npm uninstall -g --loglevel=error nemoclaw >/dev/null 2>&1; then
Expand All @@ -431,6 +443,16 @@ remove_nemoclaw_cli() {
warn "npm not found; skipping nemoclaw npm uninstall."
fi

# Fallback: if nemoclaw binary is still on PATH, remove it directly
if command -v nemoclaw >/dev/null 2>&1; then
local nemoclaw_bin
nemoclaw_bin="$(command -v nemoclaw)"
if [ -f "$nemoclaw_bin" ]; then
remove_path "$nemoclaw_bin"
info "Removed leftover nemoclaw binary at $nemoclaw_bin"
fi
Comment on lines +446 to +453
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Constrain fallback deletion to installer-managed paths and avoid hard-fail on permissions.

At Line 451, deleting command -v nemoclaw unconditionally is risky: it can remove a non-installer-managed binary and may terminate uninstall under set -e if the file is not writable.

Suggested fix
-  if command -v nemoclaw >/dev/null 2>&1; then
-    local nemoclaw_bin
-    nemoclaw_bin="$(command -v nemoclaw)"
-    if [ -f "$nemoclaw_bin" ]; then
-      remove_path "$nemoclaw_bin"
-      info "Removed leftover nemoclaw binary at $nemoclaw_bin"
-    fi
-  fi
+  if command -v nemoclaw >/dev/null 2>&1; then
+    local nemoclaw_bin
+    nemoclaw_bin="$(command -v nemoclaw)"
+    case "$nemoclaw_bin" in
+      "${NEMOCLAW_SHIM_DIR}/nemoclaw"|"$HOME"/.nvm/versions/node/*/bin/nemoclaw)
+        remove_file_with_optional_sudo "$nemoclaw_bin"
+        info "Removed leftover nemoclaw binary at $nemoclaw_bin"
+        ;;
+      *)
+        warn "Found nemoclaw at $nemoclaw_bin, but it is not an installer-managed path; leaving it in place."
+        ;;
+    esac
+  fi
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@uninstall.sh` around lines 446 - 453, Check the located nemoclaw binary (the
result of command -v nemoclaw stored in nemoclaw_bin) to ensure it lives under
installer-managed prefixes (e.g., the installer’s install dir or a known list of
managed PATH prefixes) before calling remove_path; if it is outside those
managed paths, log and skip deletion. Also avoid hard-failing on permission
errors by verifying writability (-w) before attempting removal and by making the
remove attempt tolerant to failure (e.g., try remove_path but append a non-fatal
fallback like || true or log the permission error and continue) so the script
won’t exit under set -e; keep references to the nemoclaw_bin variable,
remove_path call, and info logging when implementing these checks.

fi

if [ -L "${NEMOCLAW_SHIM_DIR}/nemoclaw" ]; then
remove_path "${NEMOCLAW_SHIM_DIR}/nemoclaw"
elif is_installer_managed_nemoclaw_shim "${NEMOCLAW_SHIM_DIR}/nemoclaw"; then
Expand Down