{"record":{"id":"84856f92a48130f0","repo":"juicedata/juicefs","slug":"failed-to-set-registry-key-s","errorCode":null,"errorMessage":"Failed to set registry key: %s","messagePattern":"Failed to set registry key: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/winfsp/winfs.go","lineNumber":1216,"sourceCode":"func 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)\n\t}\n\n\terr = k.SetStringValue(\"Executable\", filePath)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"Failed to set registry key: %s\", err)\n\t}\n","sourceCodeStart":1198,"sourceCodeEnd":1234,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/winfsp/winfs.go#L1198-L1234","documentation":"After opening/creating the WinFsp service key, the code writes the service CommandLine value. If k.SetStringValue(\"CommandLine\", cmdLine) fails, this error reports it. Values under HKLM require write access to the key.","triggerScenarios":"k.SetStringValue(\"CommandLine\", cmdLine) returns an error — e.g. the handle lacks KEY_SET_VALUE access, registry quota exhausted, or the key was opened read-only by policy.","commonSituations":"Non-elevated runs where OpenKey succeeded via a fallback path but writes are denied; security software guarding WinFsp keys; registry size limits on constrained systems.","solutions":["Re-run elevated as administrator.","Check key ACLs (KEY_SET_VALUE) for HKLM\\SOFTWARE\\WOW6432Node\\WinFsp\\Services\\<service>.","Rule out security software intercepting SetStringValue on WinFsp keys.","Read the wrapped error (%s) to identify the exact Win32 code and target the fix."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// PowerShell: verify KEY_SET_VALUE on the service key\n$k = Get-Item 'HKLM:\\SOFTWARE\\WOW6432Node\\WinFsp\\Services' -ErrorAction Stop\n$k.GetAccessControl('Access') | Format-Table AccessControlType,Rights,IdentityReference","typeGuard":null,"tryCatchPattern":"if err := registerService(); err != nil && strings.Contains(err.Error(), \"Failed to set registry key: CommandLine\") {\n    return fmt.Errorf(\"registry write denied; run elevated: %w\", err)\n}","preventionTips":["Run registration elevated so SetStringValue succeeds.","Do not let security software lock WinFsp keys.","Recreate the service key if ACLs were corrupted.","Check registry quota on constrained systems."],"tags":["windows","registry","winfsp","permissions"],"backgroundTag":"registry-write-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"}