{"record":{"id":"72c44dff558b5511","repo":"coreybutler/nvm-windows","slug":"failed-to-elevate-permissions-to-create-symlink","errorCode":null,"errorMessage":"failed to elevate permissions to create symlink","messagePattern":"failed to elevate permissions to create symlink","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/nvm.go","lineNumber":1231,"sourceCode":"\n\t\t\t\tok, err = elevatedRun(\"rmdir\", filepath.Clean(env.symlink))\n\t\t\t\t// ok, err = runElevated(fmt.Sprintf(`\"%s\" cmd /C rmdir \"%s\"`, filepath.Join(env.root, \"elevate.cmd\"), filepath.Clean(env.symlink)))\n\t\t\t\treloadable := true\n\t\t\t\tif len(reload) > 0 {\n\t\t\t\t\treloadable = reload[0]\n\t\t\t\t}\n\t\t\t\tif err != nil {\n\t\t\t\t\tstatus <- Status{Err: err, Done: true}\n\t\t\t\t} else if reloadable {\n\t\t\t\t\tuse(version, cpuarch, false)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tstatus <- Status{Err: err, Done: true}\n\t\t\t}\n\t\t}\n\t\tif !ok {\n\t\t\tstatus <- Status{Err: fmt.Errorf(\"failed to elevate permissions to create symlink\"), Done: true}\n\t\t}\n\n\t\t// Use the assigned CPU architecture\n\t\tcpuarch = arch.Validate(cpuarch)\n\t\tnodepath := filepath.Join(env.root, \"v\"+version, \"node.exe\")\n\t\tnode32path := filepath.Join(env.root, \"v\"+version, \"node32.exe\")\n\t\tnode64path := filepath.Join(env.root, \"v\"+version, \"node64.exe\")\n\t\tnode32exists := file.Exists(node32path)\n\t\tnode64exists := file.Exists(node64path)\n\t\tnodeexists := file.Exists(nodepath)\n\t\tif node32exists && cpuarch == \"32\" { // user wants 32, but node.exe is 64\n\t\t\tif nodeexists {\n\t\t\t\tutility.Rename(nodepath, node64path) // node.exe -> node64.exe\n\t\t\t}\n\t\t\tutility.Rename(node32path, nodepath) // node32.exe -> node.exe\n\t\t}\n\t\tif node64exists && cpuarch == \"64\" { // user wants 64, but node.exe is 32\n\t\t\tif nodeexists {","sourceCodeStart":1213,"sourceCodeEnd":1249,"githubUrl":"https://github.com/coreybutler/nvm-windows/blob/5b18223ca19ff50d707f35410dbc6bd440a9f74d/src/nvm.go#L1213-L1249","documentation":"Emitted by `nvm use` when the elevated helper (elevate.cmd / elevatedRun path) could not successfully create the NVM_SYMLINK junction to the selected version. Creating the symlink requires elevation on standard NTFS setups, so this means the elevation attempt failed or returned non-success (ok == false) after trying runElevated.","triggerScenarios":"Calling `nvm use <version>` where os.Symlink creation fails and the runElevated fallback (via the bundled elevate.cmd shim) reports failure: UAC prompt declined, elevate.cmd missing from NVM root, egress blocked by group policy, or symlink privileges not granted and elevation refused.","commonSituations":"User clicks 'No' on the UAC dialog; corporate policy (SeCreateSymbolicLinkPrivilege removed and UAC auto-deny); antivirus quarantining elevate.cmd; NVM root on a network/FAT volume that does not support symlinks; running in a restricted service account or CI without an interactive desktop for UAC.","solutions":["Re-run `nvm use <version>` from an elevated terminal (Run as administrator) so no UAC elevation round-trip is needed","Accept the UAC prompt when it appears; if it never appears, check that elevate.cmd exists in the NVM root","Grant the user SeCreateSymbolicLinkPrivilege via Local Security Policy (secpol.msc) and re-run","Ensure NVM_HOME/NVM_SYMLINK are on a local NTFS volume","Add an antivirus exclusion for the NVM root if elevate.cmd is being blocked"],"exampleFix":"# before (standard shell, UAC denied)\nnvm use 20.11.0\n# -> failed to elevate permissions to create symlink\n\n# after (elevated PowerShell)\nStart-Process powershell -Verb RunAs -ArgumentList 'nvm use 20.11.0'","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := useVersion(version, arch); err != nil {\n    if strings.Contains(err.Error(), \"failed to elevate permissions\") {\n        // retry from an already-elevated context or surface a UAC hint to the user\n        log.Fatal(\"run from an administrator shell, or accept the UAC prompt\")\n    }\n}","preventionTips":["Run nvm from an elevated terminal when managing versions to avoid the elevation round-trip","Keep elevate.cmd present in the NVM root; AV-exclude the NVM directory","Ensure the NVM_SYMLINK parent volume is local NTFS"],"tags":["nvm-windows","symlink","uac","permissions","windows"],"backgroundTag":null,"analyzedSha":"5b18223ca19ff50d707f35410dbc6bd440a9f74d","analyzedAt":"2026-08-15T10:06:51.428Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}