abiosoft/colima · warning
error reading pid file: %w
Error message
error reading pid file: %w
What it means
Returned by status (cmd/daemon/daemon.go:121) when the pid file exists (os.Stat succeeded) but os.ReadFile on it fails. The %w carries the read error.
Source
Thrown at cmd/daemon/daemon.go:121
case <-ctx.Done():
return ctx.Err()
default:
time.Sleep(time.Second * 1)
}
}
}
func status() error {
info := Info()
if _, err := os.Stat(info.PidFile); err != nil {
return fmt.Errorf("pid file not found: %w", err)
}
// check if process is actually running
p, err := os.ReadFile(info.PidFile)
if err != nil {
return fmt.Errorf("error reading pid file: %w", err)
}
pid, _ := strconv.Atoi(string(p))
if pid == 0 {
return fmt.Errorf("invalid pid: %v", string(p))
}
process, err := os.FindProcess(pid)
if err != nil {
return fmt.Errorf("process not found: %v", err)
}
if err := process.Signal(syscall.Signal(0)); err != nil {
return fmt.Errorf("process signal(0) returned error: %w", err)
}
return nil
}
View on GitHub (pinned to c3a5f9184d)
Solutions
- Fix ownership of the daemon directory and pid file: `sudo chown -R $(id -un) <daemon-dir>`
- If a race is likely, simply retry the status/stop command
- If no daemon is actually running (`ps aux | grep -i colima | grep daemon`), delete the unreadable pid file so status cleanly reports not-running
Defensive patterns
Strategy: validation
Validate before calling
// Probe pid file readability before daemon flows
if p, err := os.ReadFile(info.PidFile); err != nil {
return fmt.Errorf("pid file unreadable; fix ownership of the daemon dir or remove the stale pid file")
} else if pid, _ := strconv.Atoi(string(p)); pid == 0 {
return fmt.Errorf("stale pid file")
} Try / catch
if err := daemonStatus(); err != nil {
if strings.Contains(err.Error(), "error reading pid file") {
// permission or race: chown the daemon dir, or simply retry once
}
return err
} Prevention
- Never start the daemon via sudo — pid/log files become root-owned
- Avoid concurrent daemon stop/restart invocations
- If a daemon is genuinely absent, delete the stale pid file so status is clean
When it happens
Trigger: Permission denied reading the pid file (created by a root-run daemon, restrictive mode/ACL), or a race where the file is removed between stat and read (concurrent daemon stop/restart).
Common situations: Daemon previously started with sudo leaving a root-owned daemon.pid; two colima invocations racing to stop/restart the daemon.
Related errors
- cannot make dir: %w
- error reading ssh config: %w
- error modifying %s: %w
- error preparing to copy VM: %w
- config missing for colima profile '%s': %w
AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15).
Data as JSON: /api/errors/0e3af1cbdb55bbfa.
Report an issue: GitHub.