clockworklabs/SpacetimeDB · error · anyhow::Error

Server template not found

Error message

Server template not found: {}

What it means

Same invariant as the client case, but for the module side: the template definition's server_source key has no matching entry among the template files embedded in the CLI binary. Generation stops before writing `spacetimedb/`. Internal inconsistency, not a user config error.

Solutions

  1. Fall back to a stock template or `--lang rust`/`--lang csharp` to generate the server
  2. Reinstall the latest official CLI so embedded templates match the definitions
  3. Building from source: ensure templates/<server_source> exists and rebuild
  4. File an issue including the exact template name
Defensive patterns

Strategy: fallback

Prevention

When it happens

Trigger: Custom/forked CLI where a template def's server_source key is not embedded; templates directory renamed without updating defs; mixing binary versions.

Common situations: Forked CLI development; template refactors; docs describing a template newer than the installed binary.

Related errors


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

Appendix: source

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

                update_cargo_toml_name(project_path, &config.project_name)?;
            }
            Some(ClientLanguage::Csharp) => {
                update_csproj_client_to_nuget(project_path)?;
            }
            None => {}
        }
    }

    println!(
        "Setting up server ({})...",
        config.server_lang.map(|l| l.as_str()).unwrap_or("none")
    );
    let server_dir = project_path.join("spacetimedb");
    let server_source = &template_def.server_source;
    if let Some(files) = template_files.get(server_source.as_str()) {
        copy_embedded_files(files, &server_dir)?;
    } else {
        anyhow::bail!("Server template not found: {}", server_source);
    }

    // Update server name
    match config.server_lang {
        Some(ServerLanguage::TypeScript) => {
            update_package_json(&server_dir, &config.project_name)?;
        }
        Some(ServerLanguage::Rust) => {
            update_cargo_toml_name(&server_dir, &config.project_name)?;
        }
        Some(ServerLanguage::Csharp) => {
            update_csproj_server_to_nuget(&server_dir)?;
        }
        Some(ServerLanguage::Cpp) => {
            // No name update needed for C++ at the moment
        }
        None => {}
    }

View on GitHub (pinned to fdd647dfac)