{"record":{"id":"91d506544d80b56e","repo":"coreybutler/nvm-windows","slug":"failed-to-create-destination-directory-s-v","errorCode":null,"errorMessage":"failed to create destination directory %s: %v","messagePattern":"failed to create destination directory (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/upgrade/upgrade.go","lineNumber":960,"sourceCode":"\tsourceInfo, err := os.Stat(src)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get source file info: %v\", err)\n\t}\n\n\terr = os.Chmod(dst, sourceInfo.Mode())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to set file permissions: %v\", err)\n\t}\n\n\treturn nil\n}\n\n// copyDirContents copies all the contents (files and subdirectories) of a source directory to a destination directory.\nfunc copyDirContents(srcDir, dstDir string) error {\n\t// Ensure destination directory exists\n\terr := os.MkdirAll(dstDir, 0755)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to create destination directory %s: %v\", dstDir, err)\n\t}\n\n\t// Walk through the source directory recursively\n\terr = filepath.Walk(srcDir, func(srcPath string, info os.FileInfo, err error) error {\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error accessing %s: %v\", srcPath, err)\n\t\t}\n\n\t\t// Construct the corresponding path in the destination directory\n\t\trelPath, err := filepath.Rel(srcDir, srcPath)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to get relative path for %s: %v\", srcPath, err)\n\t\t}\n\n\t\tdstPath := filepath.Join(dstDir, relPath)\n\n\t\t// If it's a directory, ensure it's created in the destination\n\t\tif info.IsDir() {","sourceCodeStart":942,"sourceCodeEnd":978,"githubUrl":"https://github.com/coreybutler/nvm-windows/blob/5b18223ca19ff50d707f35410dbc6bd440a9f74d/src/upgrade/upgrade.go#L942-L978","documentation":"copyDirContents starts by creating the destination directory tree with os.MkdirAll before walking the source. This error means that MkdirAll failed — the destination path cannot be created or already exists as a file. During upgrade the destination is the live NVM_HOME, so failures here are permission or path-shape problems, not missing parents (MkdirAll creates those).","triggerScenarios":"NVM_HOME exists but the invoking user lacks write rights (Program Files install without elevation); a path component of dst is an existing regular file (e.g. a file named 'assets' where a directory is expected); NVM_HOME on an unavailable network share; path exceeds MAX_PATH on deep trees.","commonSituations":"Non-admin upgrade of a machine-wide install; corrupted install tree where a directory was replaced by a file; disconnected mapped drive hosting NVM_HOME.","solutions":["Run the upgrade from an elevated prompt.","Verify every component of the destination path is a directory, not a file, and fix any that are wrong (delete the stray file).","If NVM_HOME is on a share, reconnect it or move NVM_HOME local.","Reinstall nvm-windows if the directory structure is corrupted."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify the destination can be a directory before the tree copy\nif fi, err := os.Stat(dstDir); err == nil && !fi.IsDir() {\n    return fmt.Errorf(\"destination exists but is a file: %s\", dstDir)\n}\nif err := os.MkdirAll(dstDir, 0755); err != nil {\n    return fmt.Errorf(\"cannot create %s (permissions? run elevated): %v\", dstDir, err)\n}","typeGuard":null,"tryCatchPattern":"Fail fast with the dstDir named in the error; direct the user to elevation or ACL repair. Do not retry unchanged — permission failures do not self-heal.","preventionTips":["Install/upgrade NVM_HOME with matching privileges each time (always admin if it lives under Program Files).","Never let files squat where directories belong.","Prefer a user-writable NVM_HOME location."],"tags":["filesystem","permissions","upgrade","windows"],"backgroundTag":null,"analyzedSha":"5b18223ca19ff50d707f35410dbc6bd440a9f74d","analyzedAt":"2026-08-15T10:06:51.428Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}