fix(uninstall): source nvm in non-interactive shells to find npm#2072
fix(uninstall): source nvm in non-interactive shells to find npm#2072Sanjays2402 wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
When running `curl ... | bash`, nvm is not sourced in the non-interactive shell, so npm is not on PATH and the CLI removal step is skipped. This adds nvm auto-detection before the npm check and a fallback to directly remove the nemoclaw binary if npm uninstall fails. Fixes NVIDIA#1959
📝 WalkthroughWalkthroughUpdated the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@uninstall.sh`:
- Around line 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.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: deeee923-9065-472b-9364-a81f976fbd43
📒 Files selected for processing (1)
uninstall.sh
| # 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 |
There was a problem hiding this comment.
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.
|
✨ Thanks for submitting this PR that proposes a fix for the uninstall process to properly remove the CLI tool, which could help improve the user experience. Possibly related open issues: |
|
Thanks for the contribution @Sanjays2402 — appreciate you picking up #1959! Closing this in favor of #1965, which was opened 3 days earlier for the same issue and ended up more complete:
Please do keep contributing — happy to see more PRs from you 🙌 |
Summary\n\nWhen running
curl -fsSL .../uninstall.sh | bash, nvm is not sourced in the non-interactive shell, sonpmis not on PATH. Theremove_nemoclaw_cli()function skips CLI removal with "npm not found".\n\n## Changes\n\n1. Auto-detect nvm: Before the npm check, attempts to source$HOME/.nvm/nvm.shor$NVM_DIR/nvm.shand activate the default node version\n2. Fallback removal: After npm uninstall, ifnemoclawis still on PATH, directly removes the binary\n\nFixes #1959Summary by CodeRabbit