{"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":1775,"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":1757,"sourceCodeEnd":1793,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/fdd647dfac506d0967cc4492e9fce380706c94cb/crates/cli/src/subcommands/init.rs#L1757-L1793","documentation":"`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.","triggerScenarios":"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.","commonSituations":"Copy-pasted command lines from tutorials that added --lang on top of --template; CI scripts passing every flag defensively.","solutions":["Drop --lang and keep --template (language comes from the template)","Or drop --template and keep --lang to generate a language-specific default project","Re-check `spacetime init --help` for the current flag semantics"],"exampleFix":"# before\nspacetime init myapp --template quickstart --lang rust\n# after\nspacetime init myapp --template quickstart","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass either --template or --lang in scripts, never both","Add a lint/assert in wrapper scripts rejecting the combination before invoking the CLI"],"tags":["spacetime-init","cli","argument-validation","mutually-exclusive-flags"],"backgroundTag":"conflicting-cli-flags","analyzedSha":"fdd647dfac506d0967cc4492e9fce380706c94cb","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}