[Breaking] nvm_compare_checksum: refuse a file whose checksum cannot be verified

The empty-computed-sum branch ended with a bare `return`,
whose status is that of the preceding `nvm_err`, which is 0.
Callers treat 0 as "verified",
so an artifact that could not be verified was installed anyway,
and was even moved into the verified cache slot,
violating nvm.sh's own invariant that only a verified archive may sit at ${TARBALL}
(a later `--offline` install would then use it without any verification).

Return 1 so the artifact is rejected, as intended by #1858.

Fixes #1858

Signed-off-by: NUAAwqy <146524024+NUAAwqy@users.noreply.github.com>
Co-authored-by: NUAAwqy <146524024+NUAAwqy@users.noreply.github.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
This commit is contained in:
NUAAwqyandJordan Harband authored and Jordan Harband committed 2026-11-06 03:13:03 +00:00
1 parent 015c4f1e3b
commit 362f5e2c71
4 files changed
+22 -6

No files matched your search

+1 -1
View File
@@ -540,7 +540,7 @@ nvm install --offline 14.7.0
This resolves versions using only locally installed versions and cached downloads. It will not attempt to download anything. This is useful in air-gapped environments, on planes, or when you want to avoid network latency.
A download is only added to the cache (`$NVM_DIR/.cache`) once its checksum has been verified (unless no checksum tool is available, in which case `nvm` warns that it is continuing without verification). `--offline` does not verify cached archives again, so anything placed in the cache by other means is trusted as-is.
A download is only added to the cache (`$NVM_DIR/.cache`) once its checksum has been verified. `--offline` does not verify cached archives again, so anything placed in the cache by other means is trusted as-is.
You can combine `--offline` with `--lts` to install the latest cached LTS version (as long as LTS aliases have been populated by a prior `nvm ls-remote --lts`):