juicedata/juicefs · error
Failed to open registry key: %s
Error message
Failed to open registry key: %s
What it means
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.
Source
Thrown at pkg/winfsp/winfs.go:1209
}
return fmt.Errorf("juicefs mount command exit with error, please check the log for details")
}
const winfspSecurityDescriptor = "D:P(A;;RPWPLC;;;WD)"
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)View on GitHub (pinned to c9a67b23e8)
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.
Defensive patterns
Strategy: try-catch
Validate before calling
// PowerShell: probe open access to the WinFsp services key
try {
$k = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey('SOFTWARE\WOW6432Node\WinFsp\Services', $true)
$k.Close()
} catch { throw 'Cannot open WinFsp Services key with write access; run elevated' } Try / catch
if err := registerService(); err != nil && strings.Contains(err.Error(), "Failed to open registry key") {
// elevate and retry once
err = runElevated(registerService)
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Running without administrator rights (ALL_ACCESS requires it); registry permissions hardened by policy; the WOW6432Node WinFsp key exists but with restrictive ACLs.
Related errors
- Failed to create registry key: %s
- Failed to set registry key: %s
- Failed to delete registry key: %s
- Failed to set RunAs value: %s
- Failed to get current file path: %s
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/c8efc4aa14baf74a.
Report an issue: GitHub.