clockworklabs/SpacetimeDB · error · anyhow::Error

--native-aot is only supported for C# projects (--lang cshar

Error message

--native-aot is only supported for C# projects (--lang csharp)

What it means

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

Source

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

    }

    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
    if options.dotnet_version.is_some()
        && let Some(lang) = server_lang
        && lang.to_lowercase() != "csharp"
        && lang.to_lowercase() != "c#"
    {
        anyhow::bail!("--dotnet-version is only supported for C# projects (--lang csharp)");
    }

    if !is_interactive {

View on GitHub (pinned to 524b4487d9)

Solutions

  1. Drop --native-aot when initializing non-C# projects: `spacetime init myproj --lang rust`
  2. Or switch to C#: `spacetime init myproj --lang csharp --native-aot`
  3. If proceeding with C#, heed the printed warning: NativeAOT-LLVM building is currently supported only on Windows

Example fix

// before
spacetime init myproj --lang rust --native-aot
// after
spacetime init myproj --lang rust
Defensive patterns

Strategy: validation

Validate before calling

if [[ "$*" == *--native-aot* && "$*" == *--lang* && "$*" != *csharp* && "$*" != *'c#'* ]]; then
  echo '--native-aot requires --lang csharp' >&2; exit 2
fi
spacetime init "$@"

Prevention

When it happens

Trigger: `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.

Common situations: 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.

Related errors


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