{"record":{"id":"96ea409aa604c465","repo":"Hmbown/CodeWhale","slug":"failed-to-lock-settings-has-no-parent-director","errorCode":null,"errorMessage":"Failed to lock settings: {} has no parent directory","messagePattern":"Failed to lock settings: (.+?) has no parent directory","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/settings.rs","lineNumber":2102,"sourceCode":") -> Result<T> {\n    let path = Settings::path()?;\n    let _process_guard = lock_settings_transaction(settings_transaction_mutex(&path));\n    with_settings_file_lock(&path, || {\n        operation(&SettingsTransaction { path: path.clone() })\n    })\n}\n\n/// Hold an exclusive advisory lock on `<settings.toml>.lock` for `operation`.\n///\n/// The lock file is opened (not followed) with owner-only permissions and is\n/// created if absent. Dropping the `fd_lock` guard — including on an unwind —\n/// releases it, and the OS releases it if the process dies, so a crash cannot\n/// wedge another Codewhale instance out of its settings.\nfn with_settings_file_lock<T>(path: &Path, operation: impl FnOnce() -> Result<T>) -> Result<T> {\n    use std::fs;\n\n    let Some(parent) = path.parent().filter(|p| !p.as_os_str().is_empty()) else {\n        anyhow::bail!(\n            \"Failed to lock settings: {} has no parent directory\",\n            path.display()\n        );\n    };\n    fs::create_dir_all(parent)\n        .with_context(|| format!(\"Failed to create config directory {}\", parent.display()))?;\n\n    let mut lock_name = path\n        .file_name()\n        .context(\"Failed to lock settings: settings path has no file name\")?\n        .to_os_string();\n    lock_name.push(\".lock\");\n    let lock_path = parent.join(lock_name);\n    reject_settings_lock_symlink(&lock_path)?;\n\n    let mut options = fs::OpenOptions::new();\n    options.read(true).write(true).create(true);\n    #[cfg(unix)]","sourceCodeStart":2084,"sourceCodeEnd":2120,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/settings.rs#L2084-L2120","documentation":"The settings transaction wrapper could not establish its advisory lock file because the settings.toml path resolves to a filesystem root with no parent directory, so `<settings.toml>.lock` cannot be constructed. A path-level precondition failure before any locking is attempted.","triggerScenarios":"Thrown at crates/tui/src/settings.rs:2102 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check how the settings path was computed (custom --config overrides)","Ensure the settings file lives in a real directory"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}