juicedata/juicefs · error
Failed to set registry key
Error message
Failed to set registry key: %s
What it means
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.
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.
Defensive patterns
Strategy: try-catch
Validate before calling
// PowerShell: verify KEY_SET_VALUE on the service key
$k = Get-Item 'HKLM:\SOFTWARE\WOW6432Node\WinFsp\Services' -ErrorAction Stop
$k.GetAccessControl('Access') | Format-Table AccessControlType,Rights,IdentityReference Try / catch
if err := registerService(); err != nil && strings.Contains(err.Error(), "Failed to set registry key: CommandLine") {
return fmt.Errorf("registry write denied; run elevated: %w", err)
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to create registry key
- Failed to delete registry key
- Failed to open registry key
- Failed to set RunAs value
- Cannot find WinFsp installation path from registry, please…
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/84856f92a48130f0.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/winfsp/winfs.go:1216
func updateWinFspRegService(winfspServiceName string, cmdLine string, alias string, logPath string, asNetworkDrive bool) error {
regKeyPath := "SOFTWARE\\WOW6432Node\\WinFsp\\Services\\" + winfspServiceName
k, err := registry.OpenKey(registry.LOCAL_MACHINE, regKeyPath, registry.ALL_ACCESS)
if err != nil {
if err == syscall.ERROR_FILE_NOT_FOUND || err == syscall.ERROR_PATH_NOT_FOUND {
logger.Info("WinFsp service registry key not found, creating it.")
k, _, err = registry.CreateKey(registry.LOCAL_MACHINE, regKeyPath, registry.ALL_ACCESS)
if err != nil {
return fmt.Errorf("Failed to create registry key: %s", err)
}
} else {
return fmt.Errorf("Failed to open registry key: %s", err)
}
}
defer k.Close()
err = k.SetStringValue("CommandLine", cmdLine)
if err != nil {
return fmt.Errorf("Failed to set registry key: %s", err)
}
securityDescriptor := winfspSecurityDescriptor
err = k.SetStringValue("Security", securityDescriptor)
if err != nil {
return fmt.Errorf("Failed to set registry key: %s", err)
}
filePath, err := os.Executable()
if err != nil {
return fmt.Errorf("Failed to get current file path: %s", err)
}
err = k.SetStringValue("Executable", filePath)
if err != nil {
return fmt.Errorf("Failed to set registry key: %s", err)
}
View on GitHub (pinned to c9a67b23e8)