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

  1. Run the command elevated as administrator so ALL_ACCESS open succeeds.
  2. Inspect ACLs on HKLM\SOFTWARE\WOW6432Node\WinFsp\Services and grant the account read/write.
  3. If the hive or key is corrupt, repair via registry backup or reinstall WinFsp.
  4. 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

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


AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06). Data as JSON: /api/errors/c8efc4aa14baf74a. Report an issue: GitHub.