{"record":{"id":"33815a83654439f1","repo":"clockworklabs/SpacetimeDB","slug":"the-features-option-is-only-supported-for-rust-m","errorCode":null,"errorMessage":"The --features option is only supported for Rust modules.","messagePattern":"The --features option is only supported for Rust modules\\.","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/tasks/mod.rs","lineNumber":23,"sourceCode":"use self::cpp::build_cpp;\nuse self::csharp::build_csharp;\nuse self::javascript::build_javascript;\nuse self::rust::build_rust;\n\nuse duct::cmd;\n\n// TODO: Replace the returned `&'static str` with a copy of `HostType` from core.\npub fn build(\n    project_path: &Path,\n    lint_dir: Option<&Path>,\n    build_debug: bool,\n    features: Option<&std::ffi::OsString>,\n    native_aot: bool,\n    dotnet_version: Option<u8>,\n) -> anyhow::Result<(PathBuf, &'static str)> {\n    let lang = util::detect_module_language(project_path)?;\n    if features.is_some() && lang != ModuleLanguage::Rust {\n        anyhow::bail!(\"The --features option is only supported for Rust modules.\");\n    }\n    let output_path = match lang {\n        ModuleLanguage::Rust => build_rust(project_path, features, lint_dir, build_debug),\n        ModuleLanguage::Csharp => build_csharp(project_path, build_debug, native_aot, dotnet_version),\n        ModuleLanguage::Javascript => build_javascript(project_path, build_debug),\n        ModuleLanguage::Cpp => build_cpp(project_path, build_debug),\n    }?;\n\n    if lang == ModuleLanguage::Javascript {\n        Ok((output_path, \"Js\"))\n    } else if build_debug {\n        Ok((output_path, \"Wasm\"))\n    } else {\n        // for release builds, optimize wasm modules with wasm-opt\n        let mut wasm_path = output_path;\n        eprintln!(\"Optimising module with wasm-opt...\");\n        let wasm_path_opt = wasm_path.with_extension(\"opt.wasm\");\n        match cmd!(\"wasm-opt\", \"-all\", \"-g\", \"-O2\", &wasm_path, \"-o\", &wasm_path_opt).run() {","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/cli/src/tasks/mod.rs#L5-L41","documentation":"`spacetime build --features ...` forwards cargo features to the Rust module build. The CLI first detects the module language from the project manifest (util::detect_module_language); --features is only meaningful for Rust, so passing it for a C#, JavaScript or C++ module aborts before any build step runs.","triggerScenarios":"`spacetime build --features foo` (or generate/publish passing build options through) in a project whose language detects as C#, JavaScript or C++ -- i.e. a .csproj, package.json, or C++ manifest rather than Cargo.toml.","commonSituations":"Copy-pasting build commands between Rust and C# projects; running the command from the wrong directory in a polyglot repo so language detection picks the sibling project.","solutions":["Remove --features when building non-Rust modules.","If you expected Rust, verify you are in the module directory containing Cargo.toml so detection picks Rust.","For C#, the analogous concept is MSBuild properties in the csproj, not this flag."],"exampleFix":"# before (C# project)\nspacetime build --features shouty-ids\n# after\nspacetime build","handlingStrategy":"type-guard","validationCode":"# Only forward --features when the target is a Rust module\n[ -f \"$PROJECT/Cargo.toml\" ] && FEATURES=(--features \"$FEATURES\") || FEATURES=()\nspacetime build \"${FEATURES[@]}\"","typeGuard":"function isRustModule(dir: string): boolean {\n  // mirrors the CLI's language detection: Cargo.toml => Rust module\n  return existsSync(path.join(dir, 'Cargo.toml'));\n}","tryCatchPattern":null,"preventionTips":["Detect the module language (look for Cargo.toml vs .csproj/package.json) before composing build flags.","Keep per-language build commands in your scripts instead of one shared command with all flags."],"tags":["build","features","rust","language-detection","cli"],"backgroundTag":"unsupported-cli-option","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}