{"record":{"id":"8d8aa71e1ce4d6b4","repo":"coreybutler/nvm-windows","slug":"error-rolling-back-node-v-s-installation-v","errorCode":null,"errorMessage":"Error rolling back node v%s installation: %v.","messagePattern":"Error rolling back node v(.+?) installation: (.+?)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/nvm.go","lineNumber":413,"sourceCode":"\n\treturn version, cpuarch, err\n}\n\ntype Status struct {\n\tText string\n\tErr  error\n\tDone bool\n\tHelp bool\n}\n\nfunc rollback(version string) error {\n\tp := filepath.Join(env.root, \"v\"+version)\n\n\t_, err := os.Lstat(p)\n\tif err != nil {\n\t\tif !os.IsNotExist(err) {\n\t\t\twriteToErrorLog(err)\n\t\t\treturn fmt.Errorf(\"Error rolling back node v%s installation: %v.\", version, err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc install(version string, cpuarch string) {\n\trequestedVersion := version\n\targs := os.Args\n\tlastarg := args[len(args)-1]\n\n\tif lastarg == \"--insecure\" {\n\t\tenv.verifyssl = false\n\t}\n\n\tif strings.HasPrefix(version, \"--\") {\n\t\tfmt.Println(\"\\\"--\\\" prefixes are unnecessary in NVM for Windows!\")\n\t\tversion = strings.ReplaceAll(version, \"-\", \"\")","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/coreybutler/nvm-windows/blob/5b18223ca19ff50d707f35410dbc6bd440a9f74d/src/nvm.go#L395-L431","documentation":"Returned by rollback() when os.Lstat on <env.root>\\v<version> fails with something other than NotExist (e.g. access denied, path too long, stale handle). NotExist is the expected 'nothing to roll back' case and returns nil; any other stat failure is wrapped into this error. The name is misleading: it fires while inspecting the directory, before any deletion happens.","triggerScenarios":"During install() cleanup after a failed install, rollback() stats C:\\<nvm-root>\\v20.11.0 and hits ERROR_ACCESS_DENIED (locked by another process), ERROR_SHARING_VIOLATION (antivirus scanning), or an invalid path. It is sent on the status channel when the initial install goroutine fails and cleanup is attempted.","commonSituations":"Antivirus/Windows Defender locking freshly-created node directories; the directory is open in Explorer or a terminal; ACL/permission problems on the nvm root (e.g. root moved to a protected folder); OneDrive-synced nvm roots.","solutions":["Re-run the command as Administrator (nvm-windows normally requires elevation for its root operations).","Exclude the NVM_HOME directory from real-time antivirus scanning.","Close programs (Explorer windows, editors, running node.exe) that hold handles under the nvm root and retry.","If persistent, run `nvm uninstall <version>` to force cleanup, or manually delete <NVM_HOME>\\v<version> and reinstall."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# bash: pre-flight the target dir is stat-able and not locked\nDIR=\"$NVM_HOME/v$VERSION\"\nif [ -e \"$DIR\" ] && [ ! -w \"$DIR\" ]; then echo \"no write access to $DIR\" >&2; exit 1; fi","typeGuard":null,"tryCatchPattern":"for i in 1 2 3; do nvm install \"$V\" && break; echo \"attempt $i failed (possible file lock)\"; sleep 5; done","preventionTips":["Run nvm from an elevated shell so the nvm root is writable.","Add an antivirus exclusion for NVM_HOME.","Keep NVM_HOME off OneDrive/network-synced folders to avoid sharing violations."],"tags":["nvm-windows","filesystem","permissions","antivirus","rollback"],"backgroundTag":null,"analyzedSha":"5b18223ca19ff50d707f35410dbc6bd440a9f74d","analyzedAt":"2026-08-15T10:06:51.428Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}