clockworklabs/SpacetimeDB · error · anyhow::Error

Client template not found

Error message

Client template not found: {}

What it means

During project generation, the selected template definition names a client source directory key that is absent from the templates compiled into the CLI binary (embedded at build time via include_str!). This is an internal mapping inconsistency between TemplateDef::client_source and the embedded::get_template_files() map, not something in your code.

Solutions

  1. Retry with a stock built-in template (e.g. `--template quickstart` or `--lang rust`) to confirm the binary is healthy
  2. Update/reinstall the official CLI release so embedded templates and defs match
  3. If building from source, verify every client_source key exists under templates/ and rebuild
  4. Report the failing template name as a bug if it reproduces on an official release
Defensive patterns

Strategy: fallback

Prevention

When it happens

Trigger: A custom or newly added template definition referencing a client_source key that was never embedded; CLI built from a fork where templates/ and template defs drifted; an older CLI binary receiving a newer template name.

Common situations: Using a custom-built or forked SpacetimeDB CLI; template refactor landed for template defs but not the embedded file map; version skew between docs and installed binary.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@fdd647dfac (2026-08-20). Data as JSON: /api/errors/42f45825fe35bd2b. Report an issue: GitHub.

Appendix: source

Thrown at crates/cli/src/subcommands/init.rs:1395

    dotnet_major: Option<u8>,
) -> anyhow::Result<()> {
    let template_def = config
        .template_def
        .as_ref()
        .ok_or_else(|| anyhow::anyhow!("Template definition missing"))?;

    let template_files = embedded::get_template_files();

    if !is_server_only {
        println!(
            "Setting up client ({})...",
            config.client_lang.map(|l| l.as_str()).unwrap_or("none")
        );
        let client_source = &template_def.client_source;
        if let Some(files) = template_files.get(client_source.as_str()) {
            copy_embedded_files(files, project_path)?;
        } else {
            anyhow::bail!("Client template not found: {}", client_source);
        }

        // Update client name
        match config.client_lang {
            Some(ClientLanguage::TypeScript) => {
                update_package_json(project_path, &config.project_name)?;
                write_typescript_client_env_file(project_path, &config.project_name, config.use_local)?;
                println!(
                    "{}",
                    "Note: Run 'npm install' in the project directory to install dependencies".yellow()
                );
            }
            Some(ClientLanguage::Rust) => {
                update_cargo_toml_name(project_path, &config.project_name)?;
            }
            Some(ClientLanguage::Csharp) => {
                update_csproj_client_to_nuget(project_path)?;
            }

View on GitHub (pinned to fdd647dfac)