{"record":{"id":"0bcbd9c777c8336c","repo":"nikivdev/code","slug":"docs-template-not-found-at","errorCode":null,"errorMessage":"Docs template not found at {}","messagePattern":"Docs template not found at (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/docs.rs","lineNumber":361,"sourceCode":"                cwd.join(expanded)\n            }\n        }\n        None => project_root.to_path_buf(),\n    };\n    create_docs_scaffold_at(&target_root, opts.force)\n}\n\npub fn create_docs_scaffold_at(project_root: &Path, force: bool) -> Result<()> {\n    let docs_dir = project_root.join(PROJECT_DOCS_DIR);\n    if docs_dir.exists() {\n        if docs_dir.is_file() {\n            bail!(\"docs/ exists but is a file: {}\", docs_dir.display());\n        }\n        if !force {\n            let template_root = config::expand_path(DEFAULT_DOCS_TEMPLATE_ROOT);\n            let template_docs = template_root.join(HUB_CONTENT_ROOT);\n            if !template_docs.exists() {\n                bail!(\"Docs template not found at {}\", template_docs.display());\n            }\n            merge_docs_scaffold(&docs_dir, &template_docs)?;\n            ensure_index_file(&docs_dir, \"Docs\")?;\n            println!(\n                \"Docs already exists; merged template into {}\",\n                docs_dir.display()\n            );\n            return Ok(());\n        }\n        fs::remove_dir_all(&docs_dir)\n            .with_context(|| format!(\"failed to remove {}\", docs_dir.display()))?;\n    }\n\n    let template_root = config::expand_path(DEFAULT_DOCS_TEMPLATE_ROOT);\n    let template_docs = template_root.join(HUB_CONTENT_ROOT);\n    if !template_docs.exists() {\n        bail!(\"Docs template not found at {}\", template_docs.display());\n    }","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/docs.rs#L343-L379","documentation":"Raised by `create_docs_scaffold_at` (src/docs.rs:361) when the docs directory already exists (without `force`) and the configured docs template directory — `expand_path(DEFAULT_DOCS_TEMPLATE_ROOT)` joined with `HUB_CONTENT_ROOT` — cannot be found. The non-force path merges template content into the existing docs dir, which is impossible without the template.","triggerScenarios":"Running docs scaffold/`f setup` into an existing docs/ directory while the template root is missing: the hub/template package was never installed, the template root path in config points elsewhere or contains an unexpanded `~`/bad path, or a template version change removed HUB_CONTENT_ROOT.","commonSituations":"Custom template-root config after a tool upgrade, template deleted by a cleanup, installing the tool without its template assets, or running with HOME set to a location without the template.","solutions":["Verify the template path printed in the message exists (ls the expanded template root) and reinstall/restore the template assets if missing","Re-run with force (`--force`) if you don't need the template merge — note this skips merging template content","Correct DEFAULT_DOCS_TEMPLATE_ROOT / template config to the actual template location","Reinstall or upgrade the tool so the bundled template is present"],"exampleFix":"// before\n# template root removed by cleanup\nerror: Docs template not found at ~/.f/templates/hub/docs\n// after\nf setup --templates   # or reinstall the tool to restore templates\nf setup","handlingStrategy":"fallback","validationCode":"let tpl = dirs::home_dir().unwrap().join(\".f/templates/hub/docs\"); // match your template root\nif !tpl.is_dir() {\n    anyhow::bail!(\"docs template missing at {}; reinstall the tool or pass --force\", tpl.display());\n}","typeGuard":"fn template_available(template_root: &Path, content_root: &str) -> bool {\n    template_root.join(content_root).is_dir()\n}","tryCatchPattern":"match f_setup() {\n    Err(e) if e.to_string().starts_with(\"Docs template not found\") => {\n        eprintln!(\"{e:#}; reinstalling templates or using --force\");\n        reinstall_templates().or_else(|_| f_setup_force())?;\n    }\n    other => other?,\n}","preventionTips":["Reinstall/upgrade the tool so bundled templates exist","Validate template-root config after upgrades (path and expansion of ~)","Avoid cleanup scripts that delete template directories","Use --force only when you intentionally don't need template merge"],"tags":["docs","template","missing-asset","setup"],"backgroundTag":"template-not-found","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}