Hmbown/CodeWhale · error

Failed to lock settings: {} has no parent directory

Error message

Failed to lock settings: {} has no parent directory

What it means

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.

Source

Thrown at crates/tui/src/settings.rs:2102

) -> Result<T> {
    let path = Settings::path()?;
    let _process_guard = lock_settings_transaction(settings_transaction_mutex(&path));
    with_settings_file_lock(&path, || {
        operation(&SettingsTransaction { path: path.clone() })
    })
}

/// Hold an exclusive advisory lock on `<settings.toml>.lock` for `operation`.
///
/// The lock file is opened (not followed) with owner-only permissions and is
/// created if absent. Dropping the `fd_lock` guard — including on an unwind —
/// releases it, and the OS releases it if the process dies, so a crash cannot
/// wedge another Codewhale instance out of its settings.
fn with_settings_file_lock<T>(path: &Path, operation: impl FnOnce() -> Result<T>) -> Result<T> {
    use std::fs;

    let Some(parent) = path.parent().filter(|p| !p.as_os_str().is_empty()) else {
        anyhow::bail!(
            "Failed to lock settings: {} has no parent directory",
            path.display()
        );
    };
    fs::create_dir_all(parent)
        .with_context(|| format!("Failed to create config directory {}", parent.display()))?;

    let mut lock_name = path
        .file_name()
        .context("Failed to lock settings: settings path has no file name")?
        .to_os_string();
    lock_name.push(".lock");
    let lock_path = parent.join(lock_name);
    reject_settings_lock_symlink(&lock_path)?;

    let mut options = fs::OpenOptions::new();
    options.read(true).write(true).create(true);
    #[cfg(unix)]

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Check how the settings path was computed (custom --config overrides)
  2. Ensure the settings file lives in a real directory
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at crates/tui/src/settings.rs:2102 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/96ea409aa604c465. Report an issue: GitHub.