{"record":{"id":"fc60ca08d93e64a8","repo":"Hmbown/CodeWhale","slug":"owned-skill-root-does-not-exist","errorCode":null,"errorMessage":"owned skill root {} does not exist","messagePattern":"owned skill root (.+?) does not exist","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/skills/mutation.rs","lineNumber":202,"sourceCode":"        return Ok(());\n    }\n\n    let codewhale_dir = anchor.join(\".codewhale\");\n    let codewhale_exists = checked_real_directory(&codewhale_dir)?;\n    if !codewhale_exists {\n        if require_existing {\n            bail!(\n                \"owned skill parent {} does not exist\",\n                codewhale_dir.display()\n            );\n        }\n        return Ok(());\n    }\n\n    let skills_exists = checked_real_directory(skills_dir)?;\n    if !skills_exists {\n        if require_existing {\n            bail!(\"owned skill root {} does not exist\", skills_dir.display());\n        }\n        return Ok(());\n    }\n\n    let canonical_anchor = fs::canonicalize(anchor)\n        .with_context(|| format!(\"failed to resolve owned anchor {}\", anchor.display()))?;\n    let canonical_skills = fs::canonicalize(skills_dir).with_context(|| {\n        format!(\n            \"failed to resolve owned skill root {}\",\n            skills_dir.display()\n        )\n    })?;\n    if !canonical_skills.starts_with(&canonical_anchor) {\n        bail!(\n            \"owned skill root {} escapes anchor {}\",\n            skills_dir.display(),\n            anchor.display()\n        );","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/skills/mutation.rs#L184-L220","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-run the install/import through `prepare_owned_target`, which creates `.codewhale` and `skills` before the strict validation pass","Manually create the directory: `mkdir -p <workspace>/.codewhale/skills` (project scope) or `~/.codewhale/skills` (global scope)","Check that `<anchor>/.codewhale/skills` is a real directory, not a file or symlink; remove the impostor and recreate it","If the directory disappeared mid-operation, check for concurrent agents or cleanup scripts racing on the same workspace"],"exampleFix":"// before: validating a root that was never initialized\nlet skills = resolve_owned_target(workspace, home, scope)?;\nvalidate_owned_target_chain(&anchor, &skills, true)?; // bails: root does not exist\n// after: prepare first, which creates the chain then validates\nlet skills = prepare_owned_target(workspace, home, scope)?;","handlingStrategy":"validation","validationCode":"fn skills_root_ready(anchor: &Path) -> bool {\n    let skills = anchor.join(\".codewhale\").join(\"skills\");\n    std::fs::metadata(&skills).map(|m| m.is_dir()).unwrap_or(false)\n}\n// call before install_remote/import_external:\n// if !skills_root_ready(&workspace) { /* initialize or run prepare path */ }","typeGuard":"fn is_real_dir(p: &Path) -> bool {\n    std::fs::symlink_metadata(p).map(|m| m.is_dir()).unwrap_or(false)\n}","tryCatchPattern":"match install_remote(workspace, home, scope) {\n    Err(e) if e.to_string().contains(\"owned skill root\") => {\n        // initialize the owned chain, then retry once\n        std::fs::create_dir_all(workspace.join(\".codewhale\").join(\"skills\"))?;\n        install_remote(workspace, home, scope)\n    }\n    other => other,\n}","preventionTips":["Always initialize via prepare_owned_target rather than validating a root you did not create","Do not delete .codewhale/skills while Codewhale sessions are live in the workspace","Check with symlink_metadata that the path is a real directory, not a file or symlink","Avoid cleanup scripts that race with agent operations on the workspace"],"tags":["filesystem","directory-not-found","skills","path-validation"],"backgroundTag":"directory-not-found","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}