{"record":{"id":"bbfcb7fd823506e8","repo":"juicedata/juicefs","slug":"failed-to-create-registry-key-s","errorCode":null,"errorMessage":"Failed to create registry key: %s","messagePattern":"Failed to create registry key: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/winfsp/winfs.go","lineNumber":1206,"sourceCode":"\texitOk := host.Mount(conf.Mountpoint, []string{\"-o\", options})\n\tif exitOk {\n\t\treturn nil\n\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","sourceCodeStart":1188,"sourceCodeEnd":1224,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/winfsp/winfs.go#L1188-L1224","documentation":"updateWinFspRegService registers the WinFsp launcher service under HKLM\\SOFTWARE\\WOW6432Node\\WinFsp\\Services. When the key is absent it tries to create it; if registry.CreateKey fails, this error reports the failure. Creating the key requires write access to HKLM, typically administrator rights.","triggerScenarios":"Running registry.CreateKey(LOCAL_MACHINE, regKeyPath, ALL_ACCESS) and receiving a non-nil error — usually ERROR_ACCESS_DENIED from a non-elevated process, or registry virtualization/policy restrictions.","commonSituations":"Running `juicefs mount` from a non-admin shell or service account without HKLM write permission; Group Policy restricting registry writes; antivirus blocking registry modification.","solutions":["Re-run the mount command from an elevated (Run as administrator) prompt.","If run as a Windows service, grant the service account write access to the WinFsp Services registry key.","Check Group Policy or security software blocking HKLM writes.","Verify the underlying error string; ERROR_ACCESS_DENIED confirms a permissions fix is the right path."],"exampleFix":"// shell\n# before (non-elevated)\njuicefs mount sqlite3://test.db Z:\n# after\n# open an elevated PowerShell, then\njuicefs mount sqlite3://test.db Z:","handlingStrategy":"try-catch","validationCode":"// PowerShell: verify HKLM write access before registering the service\n$k = [Microsoft.Win32.RegistryKey]::OpenBaseKey('LocalMachine','Registry32')\ntry { $t = $k.CreateSubKey('SOFTWARE\\WOW6432Node\\WinFsp\\Services\\juicefs-test'); $t.Close() }\ncatch { throw 'No HKLM write access; run elevated' }","typeGuard":null,"tryCatchPattern":"if err := mount(); err != nil && strings.Contains(err.Error(), \"Failed to create registry key\") {\n    return fmt.Errorf(\"run as administrator to register the WinFsp service: %w\", err)\n}","preventionTips":["Run service registration from an elevated shell.","Grant service accounts HKLM write access when automating.","Check Group Policy restrictions on registry writes.","Test registry permissions as part of deployment preflight."],"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-14T05:17:10.506Z"}