nikivdev/code · error · anyhow::Error

Docs template root not found: {}

Error message

Docs template root not found: {}

What it means

ensure_docs_hub bails when the docs hub template root directory does not exist. Unlike the scaffold path, this error is raised only when template_root itself (not a subdirectory) is absent, preventing the copy of the template into hub_root and the subsequent config/layout setup steps.

Source

Thrown at src/docs.rs:421

    }

    ensure_docs_hub_deps(&hub_root)?;
    run_docs_hub_dev(&hub_root, &opts.host, opts.port, opts.no_open)
}

fn ensure_docs_hub(hub_root: &Path, template_root: &Path) -> Result<()> {
    if hub_root.join("package.json").exists() {
        sync_docs_hub_template_file(hub_root, template_root, "mdx-components.tsx", true)?;
        sync_docs_hub_template_file(hub_root, template_root, "next.config.mjs", true)?;
        sync_docs_hub_template_file(hub_root, template_root, "public/favicon.ico", false)?;
        sync_docs_hub_template_file(hub_root, template_root, "wrangler.toml", false)?;
        ensure_docs_hub_flow_toml(hub_root, template_root)?;
        ensure_docs_hub_config(hub_root)?;
        ensure_docs_hub_layout(hub_root)?;
        return Ok(());
    }
    if !template_root.exists() {
        bail!("Docs template root not found: {}", template_root.display());
    }
    fs::create_dir_all(hub_root)
        .with_context(|| format!("failed to create {}", hub_root.display()))?;
    copy_template_dir(template_root, hub_root)?;
    ensure_docs_hub_config(hub_root)?;
    ensure_docs_hub_layout(hub_root)?;
    Ok(())
}

pub fn ensure_docs_hub_daemon(opts: &DocsHubOpts) -> Result<()> {
    let focus_root = focus_project_root_from_env();
    ensure_docs_hub_daemon_with_focus(opts, focus_root.as_deref())
}

fn ensure_docs_hub_daemon_with_focus(opts: &DocsHubOpts, focus_root: Option<&Path>) -> Result<()> {
    let hub_root = config::expand_path(&opts.hub_root);
    let template_root = config::expand_path(&opts.template_root);
    println!(

View on GitHub (pinned to a747e741ae)

Solutions

  1. Check the template root path shown in the message exists on disk; correct the configured path if it moved
  2. Restore/reinstall the bundled docs template assets for this tool version
  3. Use an absolute path for a custom template root in your configuration to avoid working-directory dependence
  4. Re-run the tool's install/bootstrap step to recreate the template root

Example fix

// before (config)
template_root = "~/code/templates/docs-hub"  // deleted
// after
template_root = "~/.local/share/mytool/docs-hub-template"  // exists, absolute
Defensive patterns

Strategy: validation

Validate before calling

let template_root = config::expand_path(&cfg.template_root);
if !template_root.exists() {
    eprintln!("configured template root {} missing; restore assets or fix config", template_root.display());
    std::process::exit(1);
}
run_docs_hub(&opts)?;

Try / catch

match ensure_docs_hub(&hub_root) {
    Ok(()) => {}
    Err(e) if e.to_string().contains("Docs template root not found") => {
        eprintln!("fix template_root in config or reinstall template assets");
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling run_docs_hub, ensure_docs_hub_daemon_with_focus, or deploy_docs_hub with a hub_root whose template_root (resolved from configuration) does not exist — e.g. config points to a custom template path that was deleted, or the bundled template root was never installed.

Common situations: User overrode the template root in flow.toml/config with a typo or moved path; template assets removed by cleanup tooling; running the binary from a different working directory than expected where relative template roots no longer resolve.

Related errors


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/3eebb8da24ca29a6. Report an issue: GitHub.