Hmbown/CodeWhale · error · anyhow::Error

failed to create owned skill directory {}

Error message

failed to create owned skill directory {}

What it means

create_owned_directory called fs::create_dir and then re-validated with checked_real_directory; the latter returned false, meaning that after the create (or AlreadyExists tolerance) the path is still not a real, non-symlink directory. Typically a race replaced the path with a symlink/file between the create and the check, so the owned directory could not be established. The contested path is the input at fault.

Source

Thrown at crates/tui/src/skills/mutation.rs:234

        bail!(
            "owned skill root {} escapes anchor {}",
            skills_dir.display(),
            anchor.display()
        );
    }
    Ok(())
}

fn create_owned_directory(path: &Path) -> Result<()> {
    match fs::create_dir(path) {
        Ok(()) => {}
        Err(err) if err.kind() == ErrorKind::AlreadyExists => {}
        Err(err) => {
            return Err(err).with_context(|| format!("failed to create {}", path.display()));
        }
    }
    if !checked_real_directory(path)? {
        bail!("failed to create owned skill directory {}", path.display());
    }
    Ok(())
}

fn prepare_owned_target(
    workspace: &Path,
    home: Option<&Path>,
    target: SkillTargetScope,
) -> Result<PathBuf> {
    let skills_dir = resolve_owned_target(workspace, home, target)?;
    let anchor = owned_anchor(workspace, home, target)?;
    if !checked_real_directory(anchor)? {
        bail!("owned skill anchor {} does not exist", anchor.display());
    }

    let codewhale_dir = anchor.join(".codewhale");
    if !checked_real_directory(&codewhale_dir)? {
        create_owned_directory(&codewhale_dir)?;

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Re-run the operation; a concurrent process may have swapped the path
  2. Inspect the path for a symlink or file that replaced the directory and remove it
  3. Ensure no other tool is creating symlinks inside .codewhale
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/tui/src/skills/mutation.rs:234 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/edd9affd70595bb4. Report an issue: GitHub.