Skip to content

Fix/1357 silent extraction failure - #1362

Open
fschaupp wants to merge 2 commits into
coreybutler:masterfrom
fschaupp:fix/1357-silent-extraction-failure
Open

Fix/1357 silent extraction failure#1362
fschaupp wants to merge 2 commits into
coreybutler:masterfrom
fschaupp:fix/1357-silent-extraction-failure

Conversation

@fschaupp

Copy link
Copy Markdown

Closes #1357

Two fixes for nvm install reporting success while leaving you with no usable version.

  1. Stop masking failures. The extract/move path swallowed errors, so a failed install still printed "Complete" and left an empty version dir. Failures are now surfaced loudly and the partial install is rolled back.

  2. Fix the actual move (the real cause). Installs extract Node into a temp dir, then move it into the nvm root via utility.Rename. That only fell back to copy+delete across different volumes; on the common same-volume case it did a bare os.Rename, which on Windows fails when a freshly-extracted file is briefly
    locked (e.g. antivirus scanning node.exe). The files were left stranded in %TEMP%\nvm-install-* while nvm reported success. Rename now retries with a short backoff and falls back to copy+delete for every move — matching the manual workaround users found in the issue (copying the extracted folder into the nvm
    root).

fschaupp and others added 2 commits June 19, 2026 22:21
nvm install could report "Installation complete" while leaving an empty or
missing version directory, so nvm use failed with "Version not installed".
The install path swallowed extraction failures:

- GetNodeJS ignored fs.Move errors (only printed them) and still returned
  success, then RemoveAll deleted the un-moved files. Move errors are now
  propagated and node.exe is verified before reporting success.
- install() reported the temp->root rename failure with the wrong (nil)
  error variable, so a failed final move was silently ignored. It now
  reports the real error and aborts.
- The bundled-npm path fell through into the standalone-npm download path,
  operating on a temp directory that had just been moved away. It now
  returns once the bundled npm is in place.
- rollback() only stat'd the version directory and never removed it; a
  failed or canceled install now actually cleans up the partial directory.

This commonly triggers when the system drive is low on disk space during
extraction.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…#1357)

The install flow extracts Node into a temp directory and then moves it
into the nvm root with utility.Rename. Rename only fell back to a
copy+delete when the source and destination were on different volumes;
on the (common) same-volume case it did a bare os.Rename and returned
any error verbatim.

On Windows that rename frequently fails right after an unzip because a
file in the tree is momentarily locked (e.g. antivirus scanning the
freshly-written 100MB+ node.exe), or simply cannot be moved as a
directory entry. The maintainers already worked around this for the
standalone-npm move with an exponential backoff, but the temp->root
moves had no such handling. The result: the version directory was never
created, the fully-extracted files were left behind in
%TEMP%\nvm-install-*, and nvm still reported a successful install.

Make Rename robust for every caller:
  - retry the in-volume os.Rename with a short backoff to ride out the
    transient post-unzip lock window, then
  - fall back to a recursive copy + delete (the existing cross-volume
    path) when the rename still fails.

This matches the manual workaround reported in the issue (copy the
extracted folder into the nvm root) and complements the earlier change
that stopped the failure from being silent.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open 45 days with no activity.

@github-actions github-actions Bot added the Stale Stale label Jul 21, 2026
@fls-indinf

Copy link
Copy Markdown

bump

@github-actions github-actions Bot removed the Stale Stale label Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Issue]: nvm install reports success but fails to extract files - nvm use then says Version not installed

2 participants