{"record":{"id":"6a2577418179747b","repo":"sipeed/picoclaw","slug":"error-initializing-panic-log-v","errorCode":null,"errorMessage":"error initializing panic log: %v","messagePattern":"error initializing panic log: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"web/backend/main.go","lineNumber":443,"sourceCode":"\t\t\tos.Stderr,\n\t\t\t\"  %s -public ./config.json\\n\",\n\t\t\tos.Args[0],\n\t\t)\n\t\tfmt.Fprintf(os.Stderr, \"      Allow access from other devices on the local network\\n\")\n\t\tfmt.Fprintf(os.Stderr, \"  %s -host :: ./config.json\\n\", os.Args[0])\n\t\tfmt.Fprintf(os.Stderr, \"      Bind launcher host explicitly with exact host semantics\\n\")\n\t\tfmt.Fprintf(os.Stderr, \"  %s -console -d ./config.json\\n\", os.Args[0])\n\t\tfmt.Fprintf(os.Stderr, \"      Run in the terminal with debug logs enabled\\n\")\n\t}\n\tflag.Parse()\n\n\t// Initialize logger\n\tpicoHome := utils.GetPicoclawHome()\n\n\tf := filepath.Join(picoHome, logPath, panicFile)\n\tpanicFunc, err := logger.InitPanic(f)\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"error initializing panic log: %v\", err))\n\t}\n\tdefer panicFunc()\n\n\tenableConsole := *console\n\tfileLoggingEnabled := shouldEnableLauncherFileLogging(enableConsole, debug)\n\tif fileLoggingEnabled {\n\t\t// GUI mode writes launcher logs to file. Debug mode keeps file logging enabled in console mode too.\n\t\tif !debug {\n\t\t\tlogger.DisableConsole()\n\t\t}\n\n\t\tf := filepath.Join(picoHome, logPath, logFile)\n\t\tif err = logger.EnableFileLogging(f); err != nil {\n\t\t\tpanic(fmt.Sprintf(\"error enabling file logging: %v\", err))\n\t\t}\n\t\tdefer logger.DisableFileLogging()\n\t}\n\tif debug {","sourceCodeStart":425,"sourceCodeEnd":461,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/web/backend/main.go#L425-L461","documentation":"Launcher main() panics when logger.InitPanic(<picoclaw home>/logs/launcher_panic.log) returns an error. InitPanic (pkg/logger/panic.go:14) first MkdirAll's the directory (wrapping failures as 'failed to create log directory') and then creates the file via initPanicFile ('failed to create log file'); any failure propagates here and crashes the launcher at startup before anything else runs.","triggerScenarios":"Picoclaw home not writable; a logs path component is a regular file; disk full or quota exceeded; PICO_HOME override pointing somewhere invalid; on Windows, the panic log locked by another process.","commonSituations":"First run in a container without a writable volume; home directory created by root in an earlier run; PICO_HOME set under a read-only mount; two launcher instances sharing one home.","solutions":["Read the wrapped %v — it distinguishes directory-creation failure from file-creation failure","Make the home's logs directory writable by the runtime user, or point PICO_HOME at a writable location","Clear stale locks (previous instance) and enforce one instance per home","In container specs, add a writable volume for the home/logs path"],"exampleFix":"# docker: before (read-only fs, no volume)\n# after\nVOLUME [\"/var/lib/picoclaw\"]\nENV PICO_HOME=/var/lib/picoclaw","handlingStrategy":"validation","validationCode":"logs := filepath.Join(utils.GetPicoclawHome(), \"logs\")\nif err := os.MkdirAll(logs, 0o755); err != nil {\n    return fmt.Errorf(\"fix writability of %s before launch: %w\", logs, err)\n}\nif probe, err := os.OpenFile(filepath.Join(logs, \"launcher_panic.log\"), os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0o600); err != nil {\n    return fmt.Errorf(\"panic log not creatable: %w\", err)\n} else {\n    probe.Close()\n}","typeGuard":null,"tryCatchPattern":"Process exits at startup: handle at the deploy/supervisor layer — capture stderr, classify the wrapped error (directory vs file creation), and block the rollout until the environment is writable.","preventionTips":["Add a preflight writability check for home/logs to deploy scripts","Set PICO_HOME explicitly in every environment","Run one launcher instance per home directory"],"tags":["launcher","logger","startup","filesystem","permissions","panic"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}