{"record":{"id":"47e9955b3697e600","repo":"abiosoft/colima","slug":"error-starting-daemon-w","errorCode":null,"errorMessage":"error starting daemon: %w","messagePattern":"error starting daemon: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/daemon/daemon.go","lineNumber":41,"sourceCode":"// daemonize creates the daemon and returns if this is a child process\nfunc daemonize() (ctx *godaemon.Context, child bool, err error) {\n\tdir := dir()\n\tif err := fsutil.MkdirAll(dir, 0755); err != nil {\n\t\treturn nil, false, fmt.Errorf(\"cannot make dir: %w\", err)\n\t}\n\n\tinfo := Info()\n\n\tctx = &godaemon.Context{\n\t\tPidFileName: info.PidFile,\n\t\tPidFilePerm: 0644,\n\t\tLogFileName: info.LogFile,\n\t\tLogFilePerm: 0644,\n\t}\n\n\td, err := ctx.Reborn()\n\tif err != nil {\n\t\treturn ctx, false, fmt.Errorf(\"error starting daemon: %w\", err)\n\t}\n\tif d != nil {\n\t\treturn ctx, false, nil\n\t}\n\n\tlogrus.Info(\"- - - - - - - - - - - - - - -\")\n\tlogrus.Info(\"daemon started by colima\")\n\tlogrus.Infof(\"Run `/usr/bin/pkill -F %s` to kill the daemon\", info.PidFile)\n\n\treturn ctx, true, nil\n}\n\nfunc start(ctx context.Context, processes []process.Process) error {\n\tif status() == nil {\n\t\tlogrus.Info(\"daemon already running, startup ignored\")\n\t\treturn nil\n\t}\n","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/cmd/daemon/daemon.go#L23-L59","documentation":"Returned by daemonize (cmd/daemon/daemon.go:41) when godaemon's Context.Reborn() fails — colima could not fork/detach into the background daemon process. The %w carries the go-daemon error, which distinguishes fork failures from pid/log file problems.","triggerScenarios":"fork(2) blocked by sandboxing/seccomp or process limits (CI containers, restricted macOS contexts); daemon.pid or daemon.log under the daemon dir not writable or already locked; system out of processes; leftover unreadable pid file from a root-run daemon.","commonSituations":"Starting the daemon inside containers/CI without fork permission; stale daemon artifacts from a crashed previous run; disk full preventing log file creation.","solutions":["Read the wrapped error (%w) — a fork error points to sandbox/limits, a file error points to pid/log paths","Clear stale artifacts when no daemon is running: remove daemon.pid and daemon.log from the daemon directory","Fix ownership of the daemon directory: `sudo chown -R $(id -un) ~/.colima`","In sandboxed environments, avoid triggering the daemon (skip features that require it) or raise process/resource limits"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := daemonStart(); err != nil {\n    if strings.Contains(err.Error(), \"error starting daemon\") {\n        // fork or pid/log file failure: clear stale daemon.pid/daemon.log,\n        // fix permissions, then retry once\n        _ = os.Remove(pidFile)\n        if err2 := daemonStart(); err2 != nil {\n            return fmt.Errorf(\"daemon failed after cleanup: %w\", err2)\n        }\n    } else {\n        return err\n    }\n}","preventionTips":["Clear stale daemon.pid/daemon.log before starting when a previous daemon crashed","Avoid running the daemon in fork-restricted sandboxes (containers without process permissions)","Keep the daemon directory user-owned and on a non-full disk"],"tags":["daemon","process","fork","go-daemon","colima"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}