{"record":{"id":"9d7926ccf36bf710","repo":"clockworklabs/SpacetimeDB","slug":"project-name-is-required-in-non-interactive-mode","errorCode":null,"errorMessage":"PROJECT_NAME is required in non-interactive mode","messagePattern":"PROJECT_NAME is required in non-interactive mode","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/init.rs","lineNumber":1805,"sourceCode":"        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 {\n        // In non-interactive mode, validate all required args are present\n        if project_name_arg.is_none() {\n            anyhow::bail!(\"PROJECT_NAME is required in non-interactive mode\");\n        }\n        if template.is_none() && server_lang.is_none() {\n            anyhow::bail!(\"Either --template or --lang must be provided in non-interactive mode\");\n        }\n    }\n\n    exec_with_options(&mut config, &options).await\n}\n\npub fn init_rust_project(project_path: &Path) -> anyhow::Result<()> {\n    let export_files = vec![\n        (\n            include_str!(\"../../../../templates/basic-rs/spacetimedb/Cargo.toml\"),\n            \"Cargo.toml\",\n        ),\n        (\n            include_str!(\"../../../../templates/basic-rs/spacetimedb/src/lib.rs\"),\n            \"src/lib.rs\",","sourceCodeStart":1787,"sourceCodeEnd":1823,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/fdd647dfac506d0967cc4492e9fce380706c94cb/crates/cli/src/subcommands/init.rs#L1787-L1823","documentation":"In non-interactive mode (`-y`/`--yes`, or no TTY) init cannot prompt for the project name, so PROJECT_NAME must be a positional argument. Without it, init aborts before doing anything.","triggerScenarios":"`spacetime init -y --lang rust` with no name; running init inside CI/docker where stdin is not a terminal and flags are partially supplied.","commonSituations":"CI pipelines or Dockerfiles calling spacetime init non-interactively; scripts that assumed a prompt would appear.","solutions":["Pass the name positionally: `spacetime init my-project -y --lang rust`","Or drop -y and run interactively where you can be prompted","Audit the non-interactive call site for the full required set: name plus --template or --lang"],"exampleFix":"# before\nspacetime init -y --lang rust\n# after\nspacetime init my-project -y --lang rust","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Template your CI invocations as `spacetime init <name> -y --lang <lang>` so the name is always present","In Dockerfiles, never rely on prompts; supply every required flag"],"tags":["spacetime-init","cli","non-interactive","argument-validation"],"backgroundTag":"missing-required-argument","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"}