Hmbown/CodeWhale · error

Runtime store directory must not be a symlink

Error message

Runtime store directory must not be a symlink: {}

What it means

reject_symlinked_store_dir verifies the store directory itself is a real directory, not a symlink, to keep the store anchored at the intended location. Symlinks are rejected; non-directory paths get a separate error.

Solutions

  1. Bind-mount or configure the real directory path directly instead of symlinking
  2. Replace the symlink with a real directory and move the data
  3. Set the store root config to the symlink's target path

Example fix

// before
$ ln -s /mnt/data/runtime ~/.codewhale/runtime
// after
# in config: store_root = "/mnt/data/runtime"
$ rm ~/.codewhale/runtime
Defensive patterns

Strategy: validation

Validate before calling

fn dir_is_real(p: &Path) -> bool {
    std::fs::symlink_metadata(p).map(|m| m.is_dir() && !m.file_type().is_symlink()).unwrap_or(false)
}

Type guard

fn real_dir(p: &Path) -> Option<()> {
    let m = std::fs::symlink_metadata(p).ok()?;
    (m.is_dir() && !m.file_type().is_symlink()).then_some(())
}

Try / catch

if !dir_is_real(&store_dir) {
    let target = store_dir.read_link().unwrap_or(store_dir.to_path_buf());
    store.open(target).await?;
}

Prevention

When it happens

Trigger: The configured store directory path exists and symlink_metadata reports it is a symlink (e.g. the store root itself is a link to another location).

Common situations: Symlinking ~/.local/share/codewhale to another volume; XDG dirs replaced by links; container images pre-linking data directories.

Understand the failure class

Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/b075f3a749f64545. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/runtime_threads.rs:13913

    std::thread::sleep(EVENT_TRANSACTION_LOCK_POLL.min(timeout - elapsed));
    Ok(())
}

fn rollback_failed_event_append_handle(rollback_file: &File, original_len: u64) -> Result<()> {
    rollback_file
        .set_len(original_len)
        .context("Failed to roll back Runtime event")?;
    rollback_file
        .sync_all()
        .context("Failed to sync Runtime event rollback")
}

fn reject_symlinked_store_dir(path: &Path) -> Result<()> {
    let Ok(metadata) = fs::symlink_metadata(path) else {
        return Ok(());
    };
    if metadata.file_type().is_symlink() {
        bail!(
            "Runtime store directory must not be a symlink: {}",
            path.display()
        );
    }
    if !metadata.is_dir() {
        bail!("Runtime store path must be a directory: {}", path.display());
    }
    Ok(())
}

fn ensure_runtime_store_dir(path: &Path) -> Result<()> {
    fs::create_dir_all(path).with_context(|| format!("Failed to create {}", path.display()))?;
    reject_symlinked_store_dir(path)
}

fn read_complete_event(
    reader: &mut impl BufRead,
    path: &Path,

View on GitHub (pinned to 73e0f67d83)