{"record":{"id":"c8ab8c6e30f30c17","repo":"coreybutler/nvm-windows","slug":"nvm-symlink-is-set-to-a-physical-file-directory-at","errorCode":null,"errorMessage":"NVM_SYMLINK is set to a physical file/directory at %s\nPlease remove the location and try again, or select a different location for NVM_SYMLINK.\n","messagePattern":"NVM_SYMLINK is set to a physical file/directory at (.+?)\nPlease remove the location and try again, or select a different location for NVM_SYMLINK\\.\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/nvm.go","lineNumber":1277,"sourceCode":"\twg.Wait()\n\tos.Exit(exitCode)\n}\n\nfunc abortOnBadSymlink(symlinkpath string) {\n\tif err := validSymlink(symlinkpath); err != nil {\n\t\tfmt.Printf(\"%v\\n\", err)\n\t\tos.Exit(1)\n\t}\n}\n\nfunc validSymlink(symlinkpath string) error {\n\tsymlinkpath = filepath.Clean(symlinkpath)\n\t// Prevent deletion if the symlink has been set to a physical directpry/file.\n\t// This isn't supposed to ever happen, but users have manually changed the settings.txt,\n\t// removing the physical file/directory unintentionally.\n\t// This is an anti-footgun.\n\tif symlink, err := isSymlink(symlinkpath); !symlink && err == nil {\n\t\treturn fmt.Errorf(\"NVM_SYMLINK is set to a physical file/directory at %s\\nPlease remove the location and try again, or select a different location for NVM_SYMLINK.\\n\", env.symlink)\n\t}\n\n\treturn nil\n}\n\nfunc useArchitecture(a string) {\n\tif strings.ContainsAny(\"32\", os.Getenv(\"PROCESSOR_ARCHITECTURE\")) {\n\t\tfmt.Println(\"This computer only supports 32-bit processing.\")\n\t\treturn\n\t}\n\tif strings.Contains(\"arm64\", strings.ToLower(os.Getenv(\"PROCESSOR_ARCHITECTURE\"))) {\n\t\tfmt.Println(\"This computer only supports arm64-bit processing.\")\n\t\treturn\n\t}\n\tif a == \"32\" || a == \"64\" {\n\t\tenv.arch = a\n\t\tsaveSettings()\n\t\tfmt.Println(\"Set to \" + a + \"-bit mode\")","sourceCodeStart":1259,"sourceCodeEnd":1295,"githubUrl":"https://github.com/coreybutler/nvm-windows/blob/5b18223ca19ff50d707f35410dbc6bd440a9f74d/src/nvm.go#L1259-L1295","documentation":"Safety check in validSymlink() before `nvm use` replaces the NVM_SYMLINK path: if the symlink location exists but is a real physical file/directory (not a symlink/junction), nvm refuses to touch it to avoid deleting user data. It fires when isSymlink(path) reports 'not a symlink' with no error, i.e. something real occupies the location.","triggerScenarios":"Any `nvm use` (or nvm install triggering a use) where env.symlink points at an ordinary directory or file — commonly C:\\Program Files\\nodejs left behind by a standalone Node.js MSI install, or a user-created folder at the configured NVM_SYMLINK location.","commonSituations":"Installing nvm-windows on a machine that already had Node.js installed system-wide (the MSI's real directory sits at the symlink target); manually editing settings.txt to point root:PATH at a real folder; a previous junction converted into a copy by backup/restore software.","solutions":["Uninstall the standalone Node.js (Control Panel > Node.js) so its real directory at e.g. C:\\Program Files\\nodejs is removed, then re-run `nvm use`","Or manually delete/rename the physical folder currently occupying the NVM_SYMLINK path (after confirming nothing of value is inside)","Or edit settings.txt (symlink:PATH) / reinstall nvm-windows and choose a different NVM_SYMLINK location that is empty","Verify afterwards with `cmd /c dir /AL <parent>` that the target is now absent before retrying"],"exampleFix":"# before\n# settings.txt: symlink: C:\\Program Files\\nodejs  (real dir from old MSI install)\nnvm use 20.11.0\n# -> NVM_SYMLINK is set to a physical file/directory...\n\n# after\n# uninstall standalone Node.js, or move the folder, then:\nnvm use 20.11.0","handlingStrategy":"validation","validationCode":"func isJunction(path string) bool {\n    fi, err := os.Lstat(path)\n    if err != nil { return false }\n    return fi.Mode()&os.ModeSymlink != 0\n}\n// before nvm use:\nif _, err := os.Lstat(env.Symlink); err == nil && !isJunction(env.Symlink) {\n    log.Fatal(\"refusing to run: NVM_SYMLINK occupied by real data; move it first\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never install standalone Node.js MSI and nvm-windows against the same target path","Uninstall system-wide Node before installing nvm-windows","Treat settings.txt symlink:PATH as reserved: keep it empty of real files"],"tags":["nvm-windows","symlink","validation","windows","configuration"],"backgroundTag":null,"analyzedSha":"5b18223ca19ff50d707f35410dbc6bd440a9f74d","analyzedAt":"2026-08-15T10:06:51.428Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}