{"record":{"id":"35886c14783d00ea","repo":"sipeed/picoclaw","slug":"error-enabling-file-logging-v","errorCode":null,"errorMessage":"error enabling file logging: %v","messagePattern":"error enabling file logging: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"web/backend/main.go","lineNumber":457,"sourceCode":"\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 {\n\t\tlogger.SetLevel(logger.DEBUG)\n\t}\n\n\t// Set language from command line or auto-detect\n\tif *lang != \"\" {\n\t\tSetLanguage(*lang)\n\t}\n\n\t// Resolve config path\n\tconfigPath := utils.GetDefaultConfigPath()\n\tif flag.NArg() > 0 {\n\t\tconfigPath = flag.Arg(0)\n\t}\n","sourceCodeStart":439,"sourceCodeEnd":475,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/web/backend/main.go#L439-L475","documentation":"Launcher main() panics when logger.EnableFileLogging(<picoclaw home>/logs/launcher.log) fails during file-logging setup, which runs in GUI mode or with -debug. This is the general launcher log (distinct from the panic log); failure means the launcher cannot persist its own logs, which is treated as fatal because GUI runs would otherwise be undiagnosable.","triggerScenarios":"launcher.log locked by another process (Windows share violation from a second instance, a log viewer, or an editor with exclusive lock); directory turned read-only after the panic log was created; disk full; permissions changed between runs.","commonSituations":"Double-launching the GUI app; keeping the log open in an editor that takes exclusive locks; home directory moved between runs; ENOSPC on the logs volume.","solutions":["Close programs holding launcher.log and ensure no second launcher instance is running","Apply the same writability fixes as for the panic log (PICO_HOME, ownership, volume mounts)","Free disk space if the errno indicates no space left","As a diagnostic workaround, run with -console (file logging disabled when not in debug) to see logs on screen"],"exampleFix":"# before: two GUI instances share one home\n# after: one instance per home / per-user home\nPICO_HOME=%LOCALAPPDATA%\\Picoclaw-%USERNAME%","handlingStrategy":"validation","validationCode":"logFile := filepath.Join(utils.GetPicoclawHome(), \"logs\", \"launcher.log\")\nif probe, err := os.OpenFile(logFile, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0o644); err != nil {\n    return fmt.Errorf(\"launcher.log not writable: %w\", err)\n} else {\n    probe.Close()\n}","typeGuard":null,"tryCatchPattern":"Startup panic: the process dies before normal error handling. Handle at the supervisor level — fail the launch, show the wrapped error (lock vs permission vs disk-full), and retry only after the blocker is cleared.","preventionTips":["Enforce a single-instance guard on the home directory","Open logs read-only: copy out before viewing","Disk-space alerts on the logs volume"],"tags":["launcher","logger","startup","file-locking","filesystem","panic"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}