clockworklabs/SpacetimeDB · error · anyhow::Error
Could not detect the language of the module. Are you in a Sp
Error message
Could not detect the language of the module. Are you in a SpacetimeDB project directory?
What it means
Thrown by detect_module_language when the module directory exists but contains none of the markers the CLI recognizes: Cargo.toml (Rust), any *.csproj (C#), package.json (JavaScript/TypeScript), or CMakeLists.txt (C++). Without a marker the CLI cannot decide which toolchain to use to build the module.
Source
Thrown at crates/cli/src/util.rs:284
);
}
// check for Cargo.toml
if path_to_module.join("Cargo.toml").exists() {
Ok(ModuleLanguage::Rust)
} else if path_to_module.is_dir()
&& path_to_module
.read_dir()
.map_err(|e| anyhow::anyhow!("Failed to read directory {}: {}", path_to_module.display(), e))?
.flatten()
.any(|entry| entry.path().extension() == Some("csproj".as_ref()))
{
Ok(ModuleLanguage::Csharp)
} else if path_to_module.join("package.json").exists() {
Ok(ModuleLanguage::Javascript)
} else if path_to_module.join("CMakeLists.txt").exists() {
Ok(ModuleLanguage::Cpp)
} else {
anyhow::bail!("Could not detect the language of the module. Are you in a SpacetimeDB project directory?")
}
}
pub fn url_to_host_and_protocol(url: &str) -> anyhow::Result<(&str, &str)> {
if contains_protocol(url) {
let protocol = url.split("://").next().unwrap();
let host = url.split("://").last().unwrap();
if !VALID_PROTOCOLS.contains(&protocol) {
Err(anyhow::anyhow!("Invalid protocol: {protocol}"))
} else {
Ok((host, protocol))
}
} else {
Err(anyhow::anyhow!("Invalid url: {url}"))
}
}
View on GitHub (pinned to 524b4487d9)
Solutions
- Point the CLI at the directory that actually contains Cargo.toml, package.json, or a .csproj: `spacetime build --module-path ./module-crate`.
- Scaffold a new module: `spacetime init --lang <rust|csharp|typescript|cpp> <path>`.
- If submodules are missing: `git submodule update --init --recursive`.
- If the module is in an unsupported language, rewrite it in a supported one.
Example fix
# before — run from repo root, no manifest visible spacetime build # after — point at the crate that contains Cargo.toml spacetime build --module-path ./module-server
Defensive patterns
Strategy: validation
Validate before calling
fn is_supported_module(dir: &std::path::Path) -> bool {
if dir.join("Cargo.toml").exists() || dir.join("package.json").exists() || dir.join("CMakeLists.txt").exists() {
return true;
}
std::fs::read_dir(dir).map(|rd| rd.flatten().any(|e| e.path().extension().is_some_and(|x| x == "csproj"))).unwrap_or(false)
}
// call before invoking the CLI
assert!(is_supported_module(path.as_ref()), "no Rust/C#/JS/C++ manifest in {}", path.display()); Prevention
- Run `spacetime init` to scaffold before building.
- Keep the module manifest at the root of the module-path directory.
- Initialize git submodules after cloning.
When it happens
Trigger: Running spacetime build/publish inside a plain directory or fresh git repo that has no module scaffold; pointing --module-path at the repo root when the module is nested deeper; a module written in a language SpacetimeDB does not support; an empty directory after a partial clone or missing git submodules.
Common situations: Forgot to run `spacetime init`; cloned a project without initializing submodules; renamed or moved the module crate so its manifest file is no longer in the expected directory.
Related errors
- Could not find a SpacetimeDB module in spacetimedb/ or the c
- Fatal Error: path {} exists but is not a directory.
- Fatal Error: path {} does not exist.
- Not in a SpacetimeDB project directory
- Module directory does not exist: '{}'. Check your --module-p
AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16).
Data as JSON: /api/errors/22cf0e49ffa26f26.
Report an issue: GitHub.