Improve uninstall error message for missing versions

Include the requested version in the uninstall error output when

the target is not installed.

Add a fast test to lock the behavior.

Close #3767
This commit is contained in:
Peter Dave Hello
2026-01-30 00:04:01 +08:00
parent 6d761baef8
commit 5533699ec5
4 changed files with 38 additions and 2 deletions

8
nvm.sh
View File

@@ -3750,7 +3750,13 @@ nvm() {
fi
if ! nvm_is_version_installed "${VERSION}"; then
nvm_err "${VERSION} version is not installed..."
local REQUESTED_VERSION
REQUESTED_VERSION="${PATTERN}"
if [ "_${VERSION}" != "_N/A" ] && [ "_${VERSION}" != "_${PATTERN}" ]; then
nvm_err "Version '${VERSION}' (inferred from ${PATTERN}) is not installed."
else
nvm_err "Version '${REQUESTED_VERSION}' is not installed."
fi
return
fi