coreybutler/nvm-windows · error

error: failed to create temporary directory: %v

Error message

error: failed to create temporary directory: %v

What it means

Error "error: failed to create temporary directory: %v " thrown in coreybutler/nvm-windows.

Source

Thrown at src/upgrade/upgrade.go:380

				fmt.Println("")
			}
			for _, warning := range update.VersionWarnings {
				status <- Status{Warn: warning}
				Warn(warning, colorize)
			}
			fmt.Println("")
		}
		fmt.Printf("upgrading from v%s-->%s\n", version, highlight(update.Version))
		status <- Status{Text: "downloading..."}
	} else {
		status <- Status{Text: "nvm is up to date", Done: true}
		return nil
	}

	// Make temp directory
	tmp, err := os.MkdirTemp("", "nvm-upgrade-*")
	if err != nil {
		status <- Status{Err: fmt.Errorf("error: failed to create temporary directory: %v\n", err)}
	}
	defer os.RemoveAll(tmp)

	// Download the new app
	source := update.SourceURL
	// source := fmt.Sprintf(update.SourceURL, update.Version)
	// source := fmt.Sprintf(update.SourceURL, "1.1.11") // testing
	body, err := get(source)
	if err != nil {
		status <- Status{Err: fmt.Errorf("error: failed to download new version: %v\n", err)}
	}

	os.WriteFile(filepath.Join(tmp, "assets.zip"), body, os.ModePerm)
	os.Mkdir(filepath.Join(tmp, "assets"), os.ModePerm)

	source = source + ".checksum.txt"
	body, err = get(source)
	if err != nil {

View on GitHub (pinned to 5b18223ca1)

Solutions

  1. Check that the OS temporary directory (TMP/TEMP environment variable) points to a valid, writable location.
  2. Free up disk space on the drive hosting the temp directory.
  3. Run nvm with sufficient permissions to create directories in the temp location.
  4. Retry the upgrade; transient file system locks from antivirus or other tools can prevent temp directory creation.

When it happens

Trigger: Triggered during 'nvm upgrade' when the updater cannot create a temporary working directory (os.MkdirTemp fails). Common causes: the system TEMP/TMPDIR environment variable points to a missing, full, or read-only location; the disk hosting the temp folder is out of space; antivirus or endpoint protection blocks directory creation; or the process lacks write permission to the temp directory.

Common situations: Occurs on machines with restricted or misconfigured temp directories (e.g., corporate policies redirecting TEMP, disk-full conditions, or permission-restricted service accounts). Since the upgrade aborts at this point, no download, backup, or replacement of the nvm executable takes place, so the existing installation is left untouched. Re-running after freeing disk space or fixing the TEMP path typically succeeds.


AI-assisted analysis of coreybutler/nvm-windows@5b18223ca1 (2026-08-15). Data as JSON: /api/errors/45be75f7d8506594. Report an issue: GitHub.