clockworklabs/SpacetimeDB · error · anyhow::Error
The --features option is only supported for Rust modules.
Error message
The --features option is only supported for Rust modules.
What it means
`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.
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.
Example fix
# before (C# project) spacetime build --features shouty-ids # after spacetime build
Defensive patterns
Strategy: type-guard
Validate before calling
# Only forward --features when the target is a Rust module
[ -f "$PROJECT/Cargo.toml" ] && FEATURES=(--features "$FEATURES") || FEATURES=()
spacetime build "${FEATURES[@]}" Type guard
function isRustModule(dir: string): boolean {
// mirrors the CLI's language detection: Cargo.toml => Rust module
return existsSync(path.join(dir, 'Cargo.toml'));
} Prevention
- 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.
When it happens
Trigger: `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.
Common situations: 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.
Related errors
- Cannot determine module type from file extension
- Cannot extract accessor name from query
- --env-only cannot reset a database
- Error checking for wasm32 target
- Found disallowed print statement(s). These will not be…
AI-assisted analysis of clockworklabs/SpacetimeDB@6dee26c6ef (2026-08-20).
Data as JSON: /api/errors/33815a83654439f1.
Report an issue: GitHub.
Appendix: source
Thrown at crates/cli/src/tasks/mod.rs:23
use self::cpp::build_cpp;
use self::csharp::build_csharp;
use self::javascript::build_javascript;
use self::rust::build_rust;
use duct::cmd;
// TODO: Replace the returned `&'static str` with a copy of `HostType` from core.
pub fn build(
project_path: &Path,
lint_dir: Option<&Path>,
build_debug: bool,
features: Option<&std::ffi::OsString>,
native_aot: bool,
dotnet_version: Option<u8>,
) -> anyhow::Result<(PathBuf, &'static str)> {
let lang = util::detect_module_language(project_path)?;
if features.is_some() && lang != ModuleLanguage::Rust {
anyhow::bail!("The --features option is only supported for Rust modules.");
}
let output_path = match lang {
ModuleLanguage::Rust => build_rust(project_path, features, lint_dir, build_debug),
ModuleLanguage::Csharp => build_csharp(project_path, build_debug, native_aot, dotnet_version),
ModuleLanguage::Javascript => build_javascript(project_path, build_debug),
ModuleLanguage::Cpp => build_cpp(project_path, build_debug),
}?;
if lang == ModuleLanguage::Javascript {
Ok((output_path, "Js"))
} else if build_debug {
Ok((output_path, "Wasm"))
} else {
// for release builds, optimize wasm modules with wasm-opt
let mut wasm_path = output_path;
eprintln!("Optimising module with wasm-opt...");
let wasm_path_opt = wasm_path.with_extension("opt.wasm");
match cmd!("wasm-opt", "-all", "-g", "-O2", &wasm_path, "-o", &wasm_path_opt).run() {View on GitHub (pinned to 6dee26c6ef)