{"record":{"id":"dde3f21832a176c1","repo":"coreybutler/nvm-windows","slug":"error-failed-to-create-backup-v","errorCode":null,"errorMessage":"error: failed to create backup: %v\n","messagePattern":"error: failed to create backup: (.+?)\n","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/upgrade/upgrade.go","lineNumber":475,"sourceCode":"\t\terr = nvmtestcmd.Run()\n\t\tif err != nil {\n\t\t\tfmt.Println(\"error running nvm.exe:\", err)\n\t\t}\n\t}\n\n\t// Backup current version to zip\n\tstatus <- Status{Text: \"applying update...\"}\n\tcurrentExe, _ := os.Executable()\n\tcurrentPath := filepath.Dir(currentExe)\n\tbkp, err := os.MkdirTemp(\"\", \"nvm-backup-*\")\n\tif err != nil {\n\t\tstatus <- Status{Err: fmt.Errorf(\"error: failed to create backup directory: %v\\n\", err)}\n\t}\n\tdefer os.RemoveAll(bkp)\n\n\terr = zipDirectory(currentPath, filepath.Join(bkp, \"backup.zip\"))\n\tif err != nil {\n\t\tstatus <- Status{Err: fmt.Errorf(\"error: failed to create backup: %v\\n\", err)}\n\t}\n\n\tos.MkdirAll(filepath.Join(currentPath, \".update\"), os.ModePerm)\n\tcopyFile(filepath.Join(bkp, \"backup.zip\"), filepath.Join(currentPath, \".update\", \"nvm4w-backup.zip\"))\n\n\t// Copy the new files to the current directory\n\t// copyFile(currentExe, fmt.Sprintf(\"%s.%s.bak\", currentExe, version))\n\tcopyDirContents(filepath.Join(tmp, \"assets\"), currentPath)\n\tcopyFile(filepath.Join(tmp, \"assets\", \"nvm.exe\"), filepath.Join(currentPath, \".update/nvm.exe\"))\n\n\tif verbose {\n\t\tnvmtestcmd := exec.Command(filepath.Join(currentPath, \".update/nvm.exe\"), \"version\")\n\t\tnvmtestcmd.Stdout = os.Stdout\n\t\tnvmtestcmd.Stderr = os.Stderr\n\t\terr = nvmtestcmd.Run()\n\t\tif err != nil {\n\t\t\tstatus <- Status{Err: err}\n\t\t}","sourceCodeStart":457,"sourceCodeEnd":493,"githubUrl":"https://github.com/coreybutler/nvm-windows/blob/5b18223ca19ff50d707f35410dbc6bd440a9f74d/src/upgrade/upgrade.go#L457-L493","documentation":"nvm-windows zips the entire current installation directory into the backup temp dir before applying the new files. This error means zipDirectory failed while walking or writing the current install path — usually a file is locked or unreadable (running nvm.exe itself, node processes spawned from it, antivirus scans) or a path/permission problem inside NVM_HOME. The original installation is still untouched when this fires.","triggerScenarios":"A node.exe managed by nvm is running (its files under the symlinked version dir are locked on Windows); nvm.exe itself running from the directory being zipped; antivirus holding an exclusive handle on recently written files; path longer than MAXPATH inside the install tree; NVM_HOME on a network share with read glitches.","commonSituations":"Upgrading while a dev server or node REPL is open; upgrading from a shell whose CWD is inside NVM_HOME; OneDrive/Defender scanning the install dir mid-zip.","solutions":["Close all node processes and shells whose working directory is inside the nvm tree, then retry the upgrade.","Run the upgrade from an elevated prompt so locked-but-readable system files can still be read.","Temporarily disable real-time antivirus scanning for NVM_HOME.","If it still fails, manually back up NVM_HOME, then delete and reinstall nvm-windows fresh."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Ensure no node/nvm processes hold files in the install tree before upgrade\nout, _ := exec.Command(\"tasklist\", \"/FI\", \"IMAGENAME eq node.exe\").Output()\nif !strings.Contains(string(out), \"No tasks\") {\n    fmt.Println(\"stop node processes before upgrading\")\n}","typeGuard":null,"tryCatchPattern":"Catch, report which phase failed (backup), and reassure that the old install is intact. Direct the user to close locking processes and retry.","preventionTips":["Close all node-based dev servers, shells CWD'd inside NVM_HOME, and editors before upgrading.","Whitelist NVM_HOME in antivirus.","Keep NVM_HOME off network shares and out of synced folders."],"tags":["filesystem","backup","file-lock","upgrade"],"backgroundTag":null,"analyzedSha":"5b18223ca19ff50d707f35410dbc6bd440a9f74d","analyzedAt":"2026-08-15T10:06:51.428Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}