{"record":{"id":"22fc0a0d87f74f8c","repo":"clockworklabs/SpacetimeDB","slug":"cannot-specify-both-template-and-lang-languag","errorCode":null,"errorMessage":"Cannot specify both --template and --lang. Language is determined by the template.","messagePattern":"Cannot specify both --template and --lang\\. Language is determined by the template\\.","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/init.rs","lineNumber":1771,"sourceCode":"}\n\npub async fn exec(mut config: Config, args: &ArgMatches) -> anyhow::Result<PathBuf> {\n    let options = InitOptions::from_args(args)?;\n\n    // --template without arg prints templates list and link to website\n    if options.template.as_deref() == Some(\"\") {\n        print_templates_list().await?;\n        return Ok(PathBuf::new());\n    }\n\n    let is_interactive = !options.non_interactive;\n    let template = options.template.as_ref();\n    let server_lang = options.lang.as_ref();\n    let project_name_arg = options.project_name.as_ref();\n\n    // Validate that template and lang options are not used together\n    if template.is_some() && server_lang.is_some() {\n        anyhow::bail!(\"Cannot specify both --template and --lang. Language is determined by the template.\");\n    }\n\n    // Validate that --native-aot is only used with C# projects\n    if options.native_aot {\n        if let Some(lang) = server_lang\n            && lang.to_lowercase() != \"csharp\"\n            && lang.to_lowercase() != \"c#\"\n        {\n            anyhow::bail!(\"--native-aot is only supported for C# projects (--lang csharp)\");\n        }\n        // Print warning about Windows-only support\n        println!(\n            \"{}\",\n            \"Note: NativeAOT-LLVM is experimental and building for this platform is currently only supported on Windows.\".yellow()\n        );\n    }\n\n    // Validate that --dotnet-version is only used with C# projects","sourceCodeStart":1753,"sourceCodeEnd":1789,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/subcommands/init.rs#L1753-L1789","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Remove --lang and keep --template: `spacetime init myproj --template quickstart-csharp`","Or remove --template and keep --lang: `spacetime init myproj --lang csharp`","Run `spacetime init --template \"\"` (empty --template) to print the list of available templates, then pick one"],"exampleFix":"// before\nspacetime init myproj --template quickstart-csharp --lang csharp\n// after\nspacetime init myproj --template quickstart-csharp","handlingStrategy":"validation","validationCode":"if [[ \"$*\" == *--template* && \"$*\" == *--lang* ]]; then\n  echo 'pass only one of --template / --lang' >&2; exit 2\nfi\nspacetime init \"$@\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write new scripts with --template only; it supersedes --lang","Run `spacetime init --help` after CLI upgrades to catch flag changes","Pin the CLI version in CI so documented flags stay valid"],"tags":["cli","spacetime-init","mutually-exclusive-flags","argument-validation"],"backgroundTag":"mutually-exclusive-cli-flags","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}