Hmbown/CodeWhale · error

invalid on-disk package directory for skill

Error message

invalid on-disk package directory for skill '{}'

What it means

on_disk_package_name derives the package directory name from a skill's on-disk path and expects exactly one normal path component. If the path has a different shape (empty, nested, non-UTF8, or a special component), it errors citing the skill's canonical name.

Solutions

  1. Ensure the skill lives in exactly one plain directory directly under the skills root
  2. Remove symlinks or '..' segments from the path
  3. Rename the package directory to a plain UTF-8 name
  4. Reinstall the skill rather than hand-moving its directory

Example fix

// before: nested package path
skills/my-skill/v2/SKILL.md
// after
skills/my-skill/SKILL.md
Defensive patterns

Strategy: validation

Validate before calling

fn is_simple_dir_name(p: &std::path::Path) -> bool {
    matches!(p.components().next(), Some(std::path::Component::Normal(_)))
        && p.components().count() == 1
        && p.to_str().map_or(false, |s| !s.is_empty())
}

Try / catch

match import_external(path) {
    Ok(skill) => /* use */,
    Err(e) if e.to_string().contains("invalid on-disk package directory") => eprintln!("place the skill in a single plain directory under the skills root"),
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: validate_owned_skill_path, import_external, update_skill, or remove_skill receives a skill directory path whose final component is not a single normal directory name — e.g. skill root itself, symlink/.. components, or non-UTF8 names.

Common situations: Pointing a skill at a drive/root or nested multi-level package path; a skill id whose canonical name maps to an odd path; filesystem with non-UTF8 directory names.

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


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

Appendix: source

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

        .into_iter()
        .find(|s| &s.id == skill_id)
        .with_context(|| format!("audited skill {} not found", skill_id.canonical_name))?;
    let path = skill.root.path.join(&skill.id.relative_dir);
    Ok((skill, path))
}

/// Directory segment under the skills root. Prefer this over `canonical_name`
/// when calling install helpers that join `skills_dir / name` — installs use
/// raw frontmatter names, while audit stores a normalized lookup key.
fn on_disk_package_name(skill_id: &AuditedSkillId) -> Result<&str> {
    let mut components = skill_id.relative_dir.components();
    let name = match (components.next(), components.next()) {
        (Some(Component::Normal(name)), None) => name.to_str(),
        _ => None,
    }
    .filter(|name| !name.is_empty())
    .ok_or_else(|| {
        anyhow::anyhow!(
            "invalid on-disk package directory for skill '{}'",
            skill_id.canonical_name
        )
    })?;
    Ok(name)
}

fn verify_expected_digest(path: &Path, expected: Option<&str>) -> Result<Option<String>> {
    let current = package_digest::compute_package_digest(path)
        .with_context(|| format!("cannot digest {}", path.display()))?;
    if let Some(expected) = expected
        && expected != current
    {
        bail!(
            "skill content changed since audit (expected {expected}, found {current}); \
             re-review before mutating"
        );
    }

View on GitHub (pinned to 73e0f67d83)