clockworklabs/SpacetimeDB · error · anyhow::Error

Cannot specify both --template and --lang. Language is deter

Error message

Cannot specify both --template and --lang. Language is determined by the template.

What it means

The SpacetimeDB CLI `init` command treats --template and --lang as mutually exclusive: the chosen template already pins the server language (e.g. a C# template implies C#, a Rust template implies Rust). Passing both is ambiguous, so init rejects the combination up front, before any files are created (crates/cli/src/subcommands/init.rs:1771).

Source

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

}

pub async fn exec(mut config: Config, args: &ArgMatches) -> anyhow::Result<PathBuf> {
    let options = InitOptions::from_args(args)?;

    // --template without arg prints templates list and link to website
    if options.template.as_deref() == Some("") {
        print_templates_list().await?;
        return Ok(PathBuf::new());
    }

    let is_interactive = !options.non_interactive;
    let template = options.template.as_ref();
    let server_lang = options.lang.as_ref();
    let project_name_arg = options.project_name.as_ref();

    // Validate that template and lang options are not used together
    if template.is_some() && server_lang.is_some() {
        anyhow::bail!("Cannot specify both --template and --lang. Language is determined by the template.");
    }

    // Validate that --native-aot is only used with C# projects
    if options.native_aot {
        if let Some(lang) = server_lang
            && lang.to_lowercase() != "csharp"
            && lang.to_lowercase() != "c#"
        {
            anyhow::bail!("--native-aot is only supported for C# projects (--lang csharp)");
        }
        // Print warning about Windows-only support
        println!(
            "{}",
            "Note: NativeAOT-LLVM is experimental and building for this platform is currently only supported on Windows.".yellow()
        );
    }

    // Validate that --dotnet-version is only used with C# projects

View on GitHub (pinned to 524b4487d9)

Solutions

  1. Remove --lang and keep --template: `spacetime init myproj --template quickstart-csharp`
  2. Or remove --template and keep --lang: `spacetime init myproj --lang csharp`
  3. Run `spacetime init --template ""` (empty --template) to print the list of available templates, then pick one

Example fix

// before
spacetime init myproj --template quickstart-csharp --lang csharp
// after
spacetime init myproj --template quickstart-csharp
Defensive patterns

Strategy: validation

Validate before calling

if [[ "$*" == *--template* && "$*" == *--lang* ]]; then
  echo 'pass only one of --template / --lang' >&2; exit 2
fi
spacetime init "$@"

Prevention

When it happens

Trigger: Running `spacetime init <PROJECT_NAME> --template <t> --lang <l>` with both flags set to non-empty values in the same invocation. The check is `template.is_some() && server_lang.is_some()`, so even unrelated combinations (e.g. --template quickstart-rust --lang csharp) fail.

Common situations: Copy-pasting a command from older SpacetimeDB docs that used --lang while newer docs use --template; CI scripts or shell aliases that always pass --lang; muscle memory from other CLIs where both flags coexist.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16). Data as JSON: /api/errors/22fc0a0d87f74f8c. Report an issue: GitHub.