clockworklabs/SpacetimeDB · error · anyhow::Error

Either --template or --lang must be provided in…

Error message

Either --template or --lang must be provided in non-interactive mode

What it means

Non-interactive init has no way to ask which stack to generate, so it requires either --template (a full template) or --lang (language defaults) in addition to PROJECT_NAME. With neither, init aborts.

Solutions

  1. Add a stack: `spacetime init my-project -y --lang rust` (or csharp/typescript)
  2. Or specify a template: `spacetime init my-project -y --template quickstart`
  3. Run without -y to pick interactively

Example fix

# before
spacetime init my-project -y
# after
spacetime init my-project -y --lang rust
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: `spacetime init my-project -y` with no stack selection; CI jobs that only pass the name.

Common situations: Automated scaffolding scripts; users expecting a default template to be chosen silently.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

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

        );
    }

    // 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 {
        // In non-interactive mode, validate all required args are present
        if project_name_arg.is_none() {
            anyhow::bail!("PROJECT_NAME is required in non-interactive mode");
        }
        if template.is_none() && server_lang.is_none() {
            anyhow::bail!("Either --template or --lang must be provided in non-interactive mode");
        }
    }

    exec_with_options(&mut config, &options).await
}

pub fn init_rust_project(project_path: &Path) -> anyhow::Result<()> {
    let export_files = vec![
        (
            include_str!("../../../../templates/basic-rs/spacetimedb/Cargo.toml"),
            "Cargo.toml",
        ),
        (
            include_str!("../../../../templates/basic-rs/spacetimedb/src/lib.rs"),
            "src/lib.rs",
        ),
    ];

View on GitHub (pinned to fdd647dfac)