juicedata/juicefs · error

Failed to create registry key: %s

Error message

Failed to create registry key: %s

What it means

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.

Source

Thrown at pkg/winfsp/winfs.go:1206

	exitOk := host.Mount(conf.Mountpoint, []string{"-o", options})
	if exitOk {
		return nil
	}

	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)
	}

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Re-run the mount command from an elevated (Run as administrator) prompt.
  2. If run as a Windows service, grant the service account write access to the WinFsp Services registry key.
  3. Check Group Policy or security software blocking HKLM writes.
  4. Verify the underlying error string; ERROR_ACCESS_DENIED confirms a permissions fix is the right path.

Example fix

// shell
# before (non-elevated)
juicefs mount sqlite3://test.db Z:
# after
# open an elevated PowerShell, then
juicefs mount sqlite3://test.db Z:
Defensive patterns

Strategy: try-catch

Validate before calling

// PowerShell: verify HKLM write access before registering the service
$k = [Microsoft.Win32.RegistryKey]::OpenBaseKey('LocalMachine','Registry32')
try { $t = $k.CreateSubKey('SOFTWARE\WOW6432Node\WinFsp\Services\juicefs-test'); $t.Close() }
catch { throw 'No HKLM write access; run elevated' }

Try / catch

if err := mount(); err != nil && strings.Contains(err.Error(), "Failed to create registry key") {
    return fmt.Errorf("run as administrator to register the WinFsp service: %w", err)
}

Prevention

When it happens

Trigger: 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.

Common situations: Running `juicefs mount` from a non-admin shell or service account without HKLM write permission; Group Policy restricting registry writes; antivirus blocking registry modification.

Related errors


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