{"record":{"id":"c8efc4aa14baf74a","repo":"juicedata/juicefs","slug":"failed-to-open-registry-key-s","errorCode":null,"errorMessage":"Failed to open registry key: %s","messagePattern":"Failed to open registry key: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/winfsp/winfs.go","lineNumber":1209,"sourceCode":"\t}\n\n\treturn fmt.Errorf(\"juicefs mount command exit with error, please check the log for details\")\n}\n\nconst winfspSecurityDescriptor = \"D:P(A;;RPWPLC;;;WD)\"\n\nfunc updateWinFspRegService(winfspServiceName string, cmdLine string, alias string, logPath string, asNetworkDrive bool) error {\n\tregKeyPath := \"SOFTWARE\\\\WOW6432Node\\\\WinFsp\\\\Services\\\\\" + winfspServiceName\n\tk, err := registry.OpenKey(registry.LOCAL_MACHINE, regKeyPath, registry.ALL_ACCESS)\n\tif err != nil {\n\t\tif err == syscall.ERROR_FILE_NOT_FOUND || err == syscall.ERROR_PATH_NOT_FOUND {\n\t\t\tlogger.Info(\"WinFsp service registry key not found, creating it.\")\n\t\t\tk, _, err = registry.CreateKey(registry.LOCAL_MACHINE, regKeyPath, registry.ALL_ACCESS)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"Failed to create registry key: %s\", err)\n\t\t\t}\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"Failed to open registry key: %s\", err)\n\t\t}\n\t}\n\tdefer k.Close()\n\n\terr = k.SetStringValue(\"CommandLine\", cmdLine)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to set registry key: %s\", err)\n\t}\n\n\tsecurityDescriptor := winfspSecurityDescriptor\n\terr = k.SetStringValue(\"Security\", securityDescriptor)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to set registry key: %s\", err)\n\t}\n\n\tfilePath, err := os.Executable()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to get current file path: %s\", err)","sourceCodeStart":1191,"sourceCodeEnd":1227,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/winfsp/winfs.go#L1191-L1227","documentation":"When opening the WinFsp service registry key fails with an error other than file/path-not-found, the code cannot read or update the service registration and returns this error with the underlying cause. Only the not-found case is treated as 'create it'; every other OpenKey failure is fatal.","triggerScenarios":"registry.OpenKey(LOCAL_MACHINE, regKeyPath, registry.ALL_ACCESS) returns an error that is neither ERROR_FILE_NOT_FOUND nor ERROR_PATH_NOT_FOUND — typically ERROR_ACCESS_DENIED (non-elevated process) or a corrupted/locked hive.","commonSituations":"Running without administrator rights (ALL_ACCESS requires it); registry permissions hardened by policy; the WOW6432Node WinFsp key exists but with restrictive ACLs.","solutions":["Run the command elevated as administrator so ALL_ACCESS open succeeds.","Inspect ACLs on HKLM\\SOFTWARE\\WOW6432Node\\WinFsp\\Services and grant the account read/write.","If the hive or key is corrupt, repair via registry backup or reinstall WinFsp.","Compare the wrapped error code to decide: access denied vs structural registry problem."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// PowerShell: probe open access to the WinFsp services key\ntry {\n  $k = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey('SOFTWARE\\WOW6432Node\\WinFsp\\Services', $true)\n  $k.Close()\n} catch { throw 'Cannot open WinFsp Services key with write access; run elevated' }","typeGuard":null,"tryCatchPattern":"if err := registerService(); err != nil && strings.Contains(err.Error(), \"Failed to open registry key\") {\n    // elevate and retry once\n    err = runElevated(registerService)\n}","preventionTips":["Elevate before commands that touch HKLM.","Audit ACLs on the WinFsp Services key after hardening changes.","Reinstall WinFsp if the hive/key is corrupted.","Capture the wrapped Win32 error code for triage."],"tags":["windows","registry","winfsp","permissions"],"backgroundTag":"registry-access-failed","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}