lima-vm/lima · critical
%s: %w (result: %s)
Error message
%s: %w (result: %s)
What it means
When HcsWaitForOperationResult itself fails (non-zero HRESULT), hcsWait returns '<what>: <hresultErr> (result: <doc>)'. The result document is the HCS JSON error payload, which contains the structured HCS error code and message — this is the richest diagnostic for create/start/terminate failures. The actual VM-level failure reason is inside that JSON.
Source
Thrown at pkg/driver/hcs/hcs_api_windows.go:95
return hcsOperation(r0), nil
}
func hcsCloseOperation(op hcsOperation) {
_, _, _ = syscall.SyscallN(procHcsCloseOperation.Addr(), uintptr(op))
}
// hcsWait drives one async HCS call to completion and returns the result
// document (which carries structured error info on failure).
func hcsWait(op hcsOperation, what string, callErr error) (string, error) {
if callErr != nil {
return "", fmt.Errorf("%s: %w", what, callErr)
}
var result *uint16
r0, _, _ := syscall.SyscallN(procHcsWaitForOperationResult.Addr(),
uintptr(op), uintptr(infiniteTimeout), uintptr(unsafe.Pointer(&result)))
doc := coString(result)
if err := hresultErr(r0); err != nil {
return doc, fmt.Errorf("%s: %w (result: %s)", what, err, doc)
}
return doc, nil
}
func hcsCreateComputeSystem(id, configuration string) (hcsSystem, error) {
op, err := hcsCreateOperation()
if err != nil {
return 0, err
}
defer hcsCloseOperation(op)
idP, err := syscall.UTF16PtrFromString(id)
if err != nil {
return 0, err
}
cfgP, err := syscall.UTF16PtrFromString(configuration)
if err != nil {
return 0, errView on GitHub (pinned to dd909d0973)
Solutions
- Parse the '(result: ...)' JSON for the HCS ErrorCode/ErrorMessage to find the root cause
- Ensure the hypervisor is running: bcdedit /set hypervisorlaunchtype auto, then reboot
- Validate VM settings (memory/cpu) are within host limits in lima.yaml
- Close conflicting hypervisors (disable VirtualBox/older VMware when using WHP-based HCS)
Example fix
// before (admin prompt)
PS> bcdedit /enum | findstr hypervisorlaunchtype # shows Off
// result doc: {"ErrorCode":2151351185,...}
// after
PS> bcdedit /set hypervisorlaunchtype auto
PS> Restart-Computer Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check: hypervisor must be launched for HCS to start compute systems
// admin PowerShell: (Get-ComputerInfo).HyperVisorPresent -eq $true
if !hypervisorPresent() {
return errors.New("enable hypervisor: bcdedit /set hypervisorlaunchtype auto, then reboot")
} Try / catch
if err := limactl.Start(inst); err != nil {
if i := strings.Index(err.Error(), "(result: "); i >= 0 {
doc := err.Error()[i+len("(result: ") : len(err.Error())-1]
var hcsErr struct{ ErrorMessage string `json:"ErrorMessage"` }
if json.Unmarshal([]byte(doc), &hcsErr) == nil {
log.Printf("HCS root cause: %s", hcsErr.ErrorMessage)
}
}
return err
} Prevention
- Parse the '(result: {...})' JSON for the real HCS error before guessing fixes
- Keep hypervisorlaunchtype=auto and reboot after enabling virtualization features
- Size memory/CPU in lima.yaml within host capacity
- Avoid mixing conflicting hypervisors (VirtualBox/VMware with WHP) on one host
When it happens
Trigger: HcsWaitForOperationResult returns an error HRESULT after an async HcsCreateComputeSystem/HcsStartComputeSystem/HcsTerminateComputeSystem call — e.g. guest boot failure, bad configuration document, hypervisor not running, or resource exhaustion.
Common situations: Hyper-V/Virtual Machine Platform enabled but hypervisor not launched (bcdedit hypervisorlaunchtype off); invalid memory/CPU settings rejected by HCS; base image incompatible; WHP (Windows Hypervisor Platform) conflicts with other hypervisors (WSL2/VirtualBox).
Related errors
- unimplemented
- HcsCreateOperation: %w
- %s: %w
- configuration is nil
- --condition=boot is only supported on macOS
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/34020fb19c80bede.
Report an issue: GitHub.