juicedata/juicefs · error
Failed to set RunAs value: %s
Error message
Failed to set RunAs value: %s
What it means
Thrown when k.SetStringValue("RunAs", "LocalSystem") fails while configuring the WinFsp service's run-as account. For drive-letter mounts the library sets RunAs=LocalSystem so the launcher starts the service with system privileges; a failed write aborts registration because the service would run under the wrong account.
Source
Thrown at pkg/winfsp/winfs.go:1256
}
if logPath != "" {
err = k.SetStringValue("Stderr", logPath)
if err != nil {
return fmt.Errorf("Failed to set registry key: %s", err)
}
} else {
err = k.DeleteValue("Stderr")
if err != nil {
return fmt.Errorf("Failed to delete registry key: %s", err)
}
}
// RunAs NetworkService/LocalSystem
if !asNetworkDrive {
err = k.SetStringValue("RunAs", "LocalSystem")
if err != nil {
return fmt.Errorf("Failed to set RunAs value: %s", err)
}
} else {
k.DeleteValue("RunAs")
}
// SET "HKLM\\SOFTWARE\\WOW6432Node\\WinFsp\\MountBroadcastDriveChange" to 1
k2, err := registry.OpenKey(registry.LOCAL_MACHINE, "SOFTWARE\\WOW6432Node\\WinFsp", registry.ALL_ACCESS)
if err != nil {
logger.Warningf("Failed to open registry key for MountBroadcastDriveChange: %s", err)
} else {
defer k2.Close()
err = k2.SetDWordValue("MountBroadcastDriveChange", 1)
if err != nil {
logger.Warningf("Failed to set MountBroadcastDriveChange value: %s", err)
}
}
return nilView on GitHub (pinned to c9a67b23e8)
Solutions
- Run the mount elevated as Administrator so the RunAs value can be written.
- Verify the WinFsp\Services\juicefs-<alias> key exists; if the earlier steps succeeded it should — reinstall WinFsp if keys vanish.
- Check security software or Group Policy intercepting HKLM writes.
- Retry the mount after any WinFsp upgrade completes.
Example fix
// before (non-elevated) > juicefs mount redis://... X: // after > Start-Process juicefs -ArgumentList 'mount','redis://...','X:' -Verb RunAs
Defensive patterns
Strategy: validation
Validate before calling
// confirm HKLM write access before service registration
_, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\WOW6432Node\WinFsp\Services`, registry.SET_VALUE)
if err != nil { return errors.New("run as Administrator") } Try / catch
if err := mount(...); strings.Contains(err.Error(), "Failed to set RunAs") { /* run elevated, verify WinFsp\Services key, retry */ } Prevention
- Run drive-letter service mounts from an Administrator shell
- Don't uninstall WinFsp while a mount is being registered
- Audit security software that blocks HKLM writes
When it happens
Trigger: Mounting as a network drive... precisely: asNetworkDrive == false and the RunAs registry write fails — insufficient privileges, missing service key, or registry access restrictions.
Common situations: Non-administrator shell registering a service; corporate policy blocking HKLM writes; WinFsp Services key deleted between the earlier writes and this one (uninstall race).
Understand the failure class
Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.
Related errors
- Failed to create registry key: %s
- Failed to open registry key: %s
- Failed to set registry key: %s
- Failed to delete registry key: %s
- Failed to get current file path: %s
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/69e6d610723e50fc.
Report an issue: GitHub.