clockworklabs/SpacetimeDB · error · anyhow::Error

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

Error message

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

What it means

`spacetime init` rejects combining --template with --lang because every template already fixes its language(s); --lang only applies when generating without a template. Validation happens before any prompts or file writes.

Solutions

  1. Drop --lang and keep --template (language comes from the template)
  2. Or drop --template and keep --lang to generate a language-specific default project
  3. Re-check `spacetime init --help` for the current flag semantics

Example fix

# before
spacetime init myapp --template quickstart --lang rust
# after
spacetime init myapp --template quickstart
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Commands like `spacetime init myapp --template quickstart --lang rust`; scripts that set both flags unconditionally; muscle memory from older CLI versions where the combination was tolerated.

Common situations: Copy-pasted command lines from tutorials that added --lang on top of --template; CI scripts passing every flag defensively.

Related errors


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

Appendix: source

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

}

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 fdd647dfac)