{"record":{"id":"776baa20da5aa7f0","repo":"sipeed/picoclaw","slug":"error-in-open-panic-v","errorCode":null,"errorMessage":"error in open panic: %v","messagePattern":"error in open panic: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/logger/panic_unix.go","lineNumber":16,"sourceCode":"//go:build !windows\n\npackage logger\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\n\t\"golang.org/x/sys/unix\"\n)\n\nfunc initPanicFile(panicFile string) io.WriteCloser {\n\tfile, err := os.OpenFile(panicFile, os.O_WRONLY|os.O_CREATE|os.O_APPEND|os.O_SYNC, 0o600)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"error in open panic: %v\", err))\n\t}\n\tif err = unix.Dup2(int(file.Fd()), int(os.Stderr.Fd())); err != nil {\n\t\tpanic(fmt.Sprintf(\"error in syscall.Dup2: %v\", err))\n\t}\n\treturn file\n}\n","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/pkg/logger/panic_unix.go#L1-L23","documentation":"Startup panic in the unix build of logger.InitPanic: initPanicFile could not os.OpenFile the panic log (default <picoclaw home>/logs/launcher_panic.log) with O_WRONLY|O_CREATE|O_APPEND|O_SYNC, mode 0600. Because this file is the designated crash-output destination, failure to create it is fatal — the process aborts immediately, before logging is initialized.","triggerScenarios":"The home/logs directory is not writable by the runtime user: permission denied, read-only root filesystem/container, a path component that is a regular file, disk full/quota exceeded, or a directory previously created by root with 0700 now used by an unprivileged user.","commonSituations":"Containers with read-only FS missing a writable volume mount; first run as a different user after root created the home; PICO_HOME pointing at an invalid path; SELinux/AppArmor denials.","solutions":["Read the %v in the panic text — the errno distinguishes permission denied, read-only file system, and no space left on device","Make the logs directory writable by the service user (mkdir -p + chown/chmod)","In containers, mount a writable volume at the logs path or point PICO_HOME at a writable directory","Free space or raise quota if the errno is ENOSPC"],"exampleFix":"# before\nPICO_HOME=/opt/picoclaw ./launcher   # not writable by app user\n\n# after\nPICO_HOME=/var/lib/picoclaw ./launcher  # writable by app user","handlingStrategy":"validation","validationCode":"dir := filepath.Join(utils.GetPicoclawHome(), \"logs\")\nif err := os.MkdirAll(dir, 0o755); err != nil {\n    return fmt.Errorf(\"log dir %s unusable: %w\", dir, err)\n}\nif err := unix.Access(dir, unix.W_OK); err != nil {\n    return fmt.Errorf(\"log dir %s not writable: %w\", dir, err)\n}","typeGuard":null,"tryCatchPattern":"The panic fires before in-process error handling is usable; catch it at the supervisor level: a fast startup exit with this message is a permissions/config incident — surface the text and fail the deploy.","preventionTips":["Run a preflight writability check on the home/logs dir before InitPanic","Bake correct ownership into container images or systemd RuntimeDirectory","Never point PICO_HOME at read-only paths"],"tags":["logger","panic","unix","filesystem","startup","permissions"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}