Hmbown/CodeWhale · error

owned skill root does not exist

Error message

owned skill root {} does not exist

What it means

This error comes from `validate_owned_target_chain` when a skill operation requires an existing Codewhale-owned skills root (`<anchor>/.codewhale/skills`) but that directory does not exist. The chain validator checks each path component (anchor, `.codewhale`, `skills`) as a real, non-symlink directory; the skills root is the last one checked. It is only thrown when `require_existing` is true (post-creation validation or explicit root descriptor validation), so it means creation either never ran or silently failed to yield a real directory.

Solutions

  1. Re-run the install/import through `prepare_owned_target`, which creates `.codewhale` and `skills` before the strict validation pass
  2. Manually create the directory: `mkdir -p <workspace>/.codewhale/skills` (project scope) or `~/.codewhale/skills` (global scope)
  3. Check that `<anchor>/.codewhale/skills` is a real directory, not a file or symlink; remove the impostor and recreate it
  4. If the directory disappeared mid-operation, check for concurrent agents or cleanup scripts racing on the same workspace

Example fix

// before: validating a root that was never initialized
let skills = resolve_owned_target(workspace, home, scope)?;
validate_owned_target_chain(&anchor, &skills, true)?; // bails: root does not exist
// after: prepare first, which creates the chain then validates
let skills = prepare_owned_target(workspace, home, scope)?;
Defensive patterns

Strategy: validation

Validate before calling

fn skills_root_ready(anchor: &Path) -> bool {
    let skills = anchor.join(".codewhale").join("skills");
    std::fs::metadata(&skills).map(|m| m.is_dir()).unwrap_or(false)
}
// call before install_remote/import_external:
// if !skills_root_ready(&workspace) { /* initialize or run prepare path */ }

Type guard

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

Try / catch

match install_remote(workspace, home, scope) {
    Err(e) if e.to_string().contains("owned skill root") => {
        // initialize the owned chain, then retry once
        std::fs::create_dir_all(workspace.join(".codewhale").join("skills"))?;
        install_remote(workspace, home, scope)
    }
    other => other,
}

Prevention

When it happens

Trigger: Calling `prepare_owned_target` (via `install_remote` or `import_external`) when the final `validate_owned_target_chain(anchor, &skills_dir, true)` finds no directory at `<anchor>/.codewhale/skills` — e.g. `create_owned_directory` created something that is not a real directory, or the directory was removed between the two validation passes. Also calling `validate_owned_root_descriptor` / `resolve_owned_target` against a root whose skills directory was never initialized.

Common situations: A fresh clone or new workspace where the project has no `.codewhale/skills` yet and an operation validates before creating; the user (or a cleanup script) deleted `.codewhale/skills` mid-session; the path exists but is a file or symlink instead of a directory, so `checked_real_directory` reports false.

Related errors


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

Appendix: source

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

        return Ok(());
    }

    let codewhale_dir = anchor.join(".codewhale");
    let codewhale_exists = checked_real_directory(&codewhale_dir)?;
    if !codewhale_exists {
        if require_existing {
            bail!(
                "owned skill parent {} does not exist",
                codewhale_dir.display()
            );
        }
        return Ok(());
    }

    let skills_exists = checked_real_directory(skills_dir)?;
    if !skills_exists {
        if require_existing {
            bail!("owned skill root {} does not exist", skills_dir.display());
        }
        return Ok(());
    }

    let canonical_anchor = fs::canonicalize(anchor)
        .with_context(|| format!("failed to resolve owned anchor {}", anchor.display()))?;
    let canonical_skills = fs::canonicalize(skills_dir).with_context(|| {
        format!(
            "failed to resolve owned skill root {}",
            skills_dir.display()
        )
    })?;
    if !canonical_skills.starts_with(&canonical_anchor) {
        bail!(
            "owned skill root {} escapes anchor {}",
            skills_dir.display(),
            anchor.display()
        );

View on GitHub (pinned to 73e0f67d83)