{"record":{"id":"69951eba95e7c9d4","repo":"espanso/espanso","slug":"unable-to-set-up-log-output-file","errorCode":null,"errorMessage":"unable to set up log output file","messagePattern":"unable to set up log output file","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"espanso/src/main.rs","lineNumber":625,"sourceCode":"            info!(\"using runtime dir: {:?}\", paths.runtime.display());\n            log_system_info();\n\n            if handler.requires_config {\n                let config_result = load_config(&paths.config).expect(\"unable to load config\");\n\n                cli_args.config_store = Some(config_result.config_store);\n                cli_args.match_store = Some(config_result.match_store);\n                cli_args.non_fatal_errors = config_result.non_fatal_errors;\n            }\n\n            if handler.enable_logs {\n                log_proxy\n                    .set_output_file(\n                        &paths.runtime.join(LOG_FILE_NAME),\n                        handler.log_mode == LogMode::Read,\n                        handler.log_mode == LogMode::CleanAndAppend,\n                    )\n                    .expect(\"unable to set up log output file\");\n            }\n\n            cli_args.paths = Some(paths);\n        }\n\n        // try to invoke `kdotool` to see if you have it or not.\n        #[cfg(target_os = \"linux\")]\n        if Command::new(\"kdotool\")\n            .arg(\"getactivewindow\")\n            .arg(\"getwindowclassname\")\n            .output()\n            .is_ok()\n        {\n        } else {\n            info!(\"kdotool missing or not available for the current wayland DE.\");\n        }\n\n        if let Some(args) = matches.subcommand_matches(&handler.subcommand) {","sourceCodeStart":607,"sourceCodeEnd":643,"githubUrl":"https://github.com/espanso/espanso/blob/e6c3736675048026a057f1c4803d59242482fa7b/espanso/src/main.rs#L607-L643","documentation":"After config loading, main attaches a log output file in the runtime directory via log_proxy.set_output_file(...).expect(...). The expect fires if opening/creating the log file fails or if the FileProxy lock is poisoned (error 143 path).","triggerScenarios":"set_output_file returns Err: the runtime directory doesn't exist, is read-only, or denies write permission; disk full; or the underlying Mutex is poisoned from an earlier panic (LogMode::Read / CleanAndAppend flags passed from the handler).","commonSituations":"Runtime dir deleted or mounted read-only (sandboxed/Flatpak setups, read-only /run), permission mismatch after running espanso as different users, disk-full, or a prior panic poisoning the log mutex.","solutions":["Recreate the runtime directory and fix permissions (`espanso path` shows it; typically `mkdir -p <runtime>` and chown to the running user).","Check disk space (df -h) if the filesystem is full.","Run espanso as the same user that owns the runtime dir; avoid mixing sudo/non-sudo runs.","Verify the earlier panic (if 'unable to obtain FileProxy lock' preceded this) and fix its root cause.","Update or patch espanso to degrade gracefully (keep memory-only logging) when the file can't be opened."],"exampleFix":"// before\nlog_proxy\n    .set_output_file(&paths.runtime.join(LOG_FILE_NAME), read, clean)\n    .expect(\"unable to set up log output file\");\n// after\nif let Err(err) = log_proxy.set_output_file(&paths.runtime.join(LOG_FILE_NAME), read, clean) {\n    eprintln!(\"warning: falling back to memory logging: {err}\");\n}","handlingStrategy":"fallback","validationCode":"let log_path = paths.runtime.join(LOG_FILE_NAME);\nif let Err(e) = std::fs::OpenOptions::new().append(true).create(true).open(&log_path) {\n    eprintln!(\"cannot write log file {}: {e}\", log_path.display());\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = log_proxy.set_output_file(&log_path, read, clean) {\n    eprintln!(\"warning: memory-only logging: {e}\");\n}","preventionTips":["Ensure the runtime dir exists and is writable by the espanso user","Avoid mixing sudo and normal-user runs (ownership drift)","Monitor disk space on the runtime filesystem","Fix preceding panics that can poison the log mutex"],"tags":["rust","logging","file-io","permissions"],"backgroundTag":"file-write-failed","analyzedSha":"e6c3736675048026a057f1c4803d59242482fa7b","analyzedAt":"2026-09-06T15:16:34.240Z","contentChangedAt":"2026-09-06T15:16:34.240Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}