lima-vm/lima · error
failed to convert output from UTF16 when running command %v,
Error message
failed to convert output from UTF16 when running command %v, err: %w
What it means
RunUTF16leCommand runs a command (typically Windows wsl.exe, which emits UTF-16LE output) and converts the combined output from UTF-16LE to a Go string; this error wraps the conversion failure from strutil.FromUTF16leToString. It indicates the command's output was not valid UTF-16LE, so it cannot be decoded.
Source
Thrown at pkg/executil/command.go:49
for _, f := range opts {
if err := f(&o); err != nil {
return "", err
}
}
var cmd *exec.Cmd
ctx := o.ctx
if ctx == nil {
ctx = context.Background()
}
cmd = exec.CommandContext(ctx, args[0], args[1:]...)
outString := ""
out, err := cmd.CombinedOutput()
if out != nil {
s, err := strutil.FromUTF16leToString(bytes.NewReader(out))
if err != nil {
return "", fmt.Errorf("failed to convert output from UTF16 when running command %v, err: %w", args, err)
}
outString = s
}
return outString, err
}
View on GitHub (pinned to dd909d0973)
Solutions
- Inspect the wrapped conversion error to see the malformed byte issue
- Run the underlying WSL command manually (e.g. `wsl.exe --status`) to inspect its raw output encoding
- Ensure Windows console code page/locales are standard (chcp 65001) and wsl.exe is up to date (`wsl --update`)
- Check that the command isn't failing and emitting non-UTF16 error text; handle err from cmd execution separately
Defensive patterns
Strategy: try-catch
Validate before calling
// verify wsl.exe is present and produces output before relying on it
if _, err := exec.LookPath("wsl.exe"); err != nil {
return errors.New("wsl.exe not available")
} Try / catch
out, err := executil.RunUTF16leCommand(ctx, args...)
if err != nil {
if strings.Contains(err.Error(), "failed to convert output from UTF16") {
// fall back to raw output / log for diagnosis
log.Warnf("non-UTF16 output from wsl: %v", err)
}
return err
} Prevention
- Keep wsl.exe updated (wsl --update)
- Avoid custom console code pages that alter output encoding
- Handle command failures before decoding output
- Test on target Windows locales
When it happens
Trigger: Calling RunUTF16leCommand (used by startVM, initVM, stopVM, unregisterVM, getWslStatus) when the executed command's output is not valid UTF-16LE — e.g. an odd byte count or malformed surrogate pairs in the combined output.
Common situations: wsl.exe emitting localized/odd-encoded output on some Windows configurations; the command writing binary or plain-ASCII error output instead of UTF-16; a corrupted or legacy code page in the Windows console.
Related errors
- --condition=boot is only supported on macOS
- failed to register instance %#q to start at login: %w
- cannot use `--sync` with a wsl2 instance, the host directory
- expected the depth of the converted host working directory (
- unsupported shell %#q for Windows guest, must be one of %v
AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01).
Data as JSON: /api/errors/b5f428226086fad9.
Report an issue: GitHub.