[Fix] nvm install: do not remove the caller's TMPDIR after a failed download

`nvm_install_binary` and `nvm_install_source` declared `local TMPDIR` without initializing it, and remove it with `rm -rf` on failure. dash's `local` keeps the caller's value, as does bash's when `TMPDIR` is passed as a prefix assignment (`TMPDIR=… nvm install`), so a failed download removed the caller's temp directory; on macOS, `tar` instead blocked reading the archive from the terminal.
This commit is contained in:
Jordan Harband committed 2026-10-05 10:02:48 -07:00
1 parent a8bb497400
commit 04ac3f2a83
2 files changed
+38

No files matched your search

+8
View File
@@ -2775,8 +2775,12 @@ nvm_install_binary() {
return 2
fi
# dash's `local` keeps the caller's value, and TMPDIR is usually set: it is
# later removed with `rm -rf`, so it must not start as the system temp dir
local TARBALL
TARBALL=''
local TMPDIR
TMPDIR=''
local PROGRESS_BAR
local NODE_OR_IOJS
@@ -3176,9 +3180,13 @@ nvm_install_source() {
fi
fi
# see nvm_install_binary: these must not inherit TMPDIR, which is removed on failure
local TARBALL
TARBALL=''
local TMPDIR
TMPDIR=''
local VERSION_PATH
VERSION_PATH=''
if [ "${NVM_NO_PROGRESS-}" = "1" ]; then
# --silent, --show-error, use short option as @samrocketman mentions the compatibility issue.