abiosoft/colima · error
error encoding status as json: %w
Error message
error encoding status as json: %w
What it means
With `colima status --json`, the status struct is streamed to stdout via json.Encoder; the error surfaces only when writing to stdout fails, almost always a closed or broken pipe (e.g. piping into head) rather than an encoding problem, since statusInfo is a plain fixed-shape struct.
Source
Thrown at app/app.go:423
status.Kubernetes = true
}
if inst, err := limautil.Instance(); err == nil {
status.CPU = inst.CPU
status.Memory = inst.Memory
status.Disk = inst.Disk
}
return status, nil
}
func (c colimaApp) Status(extended bool, jsonOutput bool) error {
status, err := c.getStatus()
if err != nil {
return err
}
if jsonOutput {
if err := json.NewEncoder(os.Stdout).Encode(status); err != nil {
return fmt.Errorf("error encoding status as json: %w", err)
}
} else {
log.Println(config.CurrentProfile().DisplayName, "is running using", status.Driver)
log.Println("arch:", status.Arch)
log.Println("runtime:", status.Runtime)
if status.MountType != "" {
log.Println("mountType:", status.MountType)
}
// ip address
if status.IPAddress != "" {
log.Println("address:", status.IPAddress)
}
// docker socket
if status.DockerSocket != "" {
log.Println("docker socket:", status.DockerSocket)
}View on GitHub (pinned to c3a5f9184d)
Solutions
- Buffer the output instead of early-exiting the consumer: `colima status -j > /tmp/status.json`
- In pipelines, drop the truncating command or run with pipefail disabled so SIGPIPE is not fatal
- When embedding, capture to a buffer/file rather than a live pipe
- Check disk space if stdout is redirected to a file
Example fix
# before colima status --json | head -1 # broken pipe # after colima status --json > /tmp/colima-status.json head -1 /tmp/colima-status.json
Defensive patterns
Strategy: try-catch
Type guard
func isBrokenPipe(err error) bool {
return err != nil && (errors.Is(err, syscall.EPIPE) || strings.Contains(err.Error(), "broken pipe"))
} Try / catch
// capture to a buffer instead of a live pipe
var buf bytes.Buffer
if err := json.NewEncoder(&buf).Encode(status); err != nil {
return err // encoding should never fail for statusInfo
}
// write buf once; treat EPIPE on stdout as consumer-exited-early, not an error Prevention
- Avoid early-exiting consumers of `colima status --json` (head, less -q)
- Redirect json output to a file when parsing it in scripts
- Handle or ignore SIGPIPE in wrappers around colima
When it happens
Trigger: `colima status -j | head -1` where the consumer exits early (EPIPE), stdout redirected to a full device, or stdout closed prematurely by the calling process.
Common situations: Piping json output into head/less and quitting early; output redirected to a full disk or over a file-handle limit; embedding colima in a process whose stdout is closed before the write completes.
Related errors
- %s not running
- %s is not running
- pid file not found: %w
- error decoding 'limactl info' json: %w
- inotify not running
AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15).
Data as JSON: /api/errors/ff9ad575efdad07d.
Report an issue: GitHub.