{"record":{"id":"d915a1bc0e6b1b19","repo":"clockworklabs/SpacetimeDB","slug":"native-aot-is-only-supported-for-c-projects","errorCode":null,"errorMessage":"--native-aot is only supported for C# projects (--lang csharp)","messagePattern":"--native-aot is only supported for C# projects \\(--lang csharp\\)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/init.rs","lineNumber":1780,"sourceCode":"    }\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\n    if options.dotnet_version.is_some()\n        && let Some(lang) = server_lang\n        && lang.to_lowercase() != \"csharp\"\n        && lang.to_lowercase() != \"c#\"\n    {\n        anyhow::bail!(\"--dotnet-version is only supported for C# projects (--lang csharp)\");\n    }\n\n    if !is_interactive {","sourceCodeStart":1762,"sourceCodeEnd":1798,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/subcommands/init.rs#L1762-L1798","documentation":"--native-aot switches the generated C# module to experimental NativeAOT-LLVM compilation, which the SpacetimeDB toolchain only implements for C#. init rejects --native-aot when --lang is set to anything other than csharp or c# (compared case-insensitively) (init.rs:1780).","triggerScenarios":"`spacetime init myproj --lang rust --native-aot`, `--lang typescript --native-aot`, or any non-C# --lang value combined with --native-aot. Note: a --template plus --native-aot is not checked here because template+lang together already fail at error 160.","commonSituations":"Assuming AOT applies to all module languages; enabling --native-aot unconditionally in a shared init script; copying flags from a C# example into a Rust or TypeScript project.","solutions":["Drop --native-aot when initializing non-C# projects: `spacetime init myproj --lang rust`","Or switch to C#: `spacetime init myproj --lang csharp --native-aot`","If proceeding with C#, heed the printed warning: NativeAOT-LLVM building is currently supported only on Windows"],"exampleFix":"// before\nspacetime init myproj --lang rust --native-aot\n// after\nspacetime init myproj --lang rust","handlingStrategy":"validation","validationCode":"if [[ \"$*\" == *--native-aot* && \"$*\" == *--lang* && \"$*\" != *csharp* && \"$*\" != *'c#'* ]]; then\n  echo '--native-aot requires --lang csharp' >&2; exit 2\nfi\nspacetime init \"$@\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Reserve --native-aot for C# modules","Remember NativeAOT-LLVM builds currently work only on Windows","Keep language-specific flags out of shared init scripts"],"tags":["cli","native-aot","csharp","argument-validation"],"backgroundTag":"unsupported-flag-combination","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}