clockworklabs/SpacetimeDB · error · anyhow::Error
Unknown server language
Error message
Unknown server language: {} What it means
`spacetime init` parses the server language string via ServerLanguage::from_str. Accepted values after lowercasing: rust, csharp (alias c#), typescript, cpp (aliases c++, cxx). Any other string is rejected with 'Unknown server language: <s>'. The check is case-insensitive, but whitespace is not trimmed and spelling variants beyond the listed aliases fail.
Solutions
- Use one of the accepted values: rust, csharp (or c#), typescript, cpp (or c++, cxx)
- Trim and normalize the value in scripts before passing it (lowercase, strip spaces)
- Check `spacetime init --help` for your CLI version's accepted list
Example fix
# before spacetime init --lang "C++ " # after spacetime init --lang cpp
Defensive patterns
Strategy: validation
Validate before calling
#!/usr/bin/env bash
SERVER_LANGS='rust|csharp|c#|typescript|cpp|c++|cxx'
lang="$(echo "$1" | tr '[:upper:]' '[:lower:]' | xargs)"
[[ "$lang" =~ ^($SERVER_LANGS)$ ]] || { echo "server lang must be: $SERVER_LANGS" >&2; exit 2; }
spacetime init --lang "$lang" Prevention
- Normalize case and trim whitespace before passing --lang in scripts
- Use canonical spellings: rust, csharp, typescript, cpp
- Check `spacetime init --help` after CLI upgrades — accepted language sets change between versions
When it happens
Trigger: Passing `spacetime init --lang <s>` (server language flag) with an unsupported value such as 'go', 'python', 'C #', 'cplus', or a value with leading/trailing whitespace. Also triggered by automation piping a language name from another tool's output verbatim.
Common situations: Assuming a language exists because the client SDK does (e.g. 'unity' or 'python' is not a server language); shell scripts echoing 'C++' with odd quoting/whitespace; documentation drift between CLI versions where accepted sets changed.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Unknown client language
- Either --out-dir or --uproject-dir is required
- --namespace is only supported with --lang csharp
- --unreal-module-name is required for --lang unrealcpp
- --uproject-dir is required for --lang unrealcpp
AI-assisted analysis of clockworklabs/SpacetimeDB@fdd647dfac (2026-08-20).
Data as JSON: /api/errors/2e190be2beb40fb0.
Report an issue: GitHub.
Appendix: source
Thrown at crates/cli/src/subcommands/init.rs:80
}
impl ServerLanguage {
fn as_str(&self) -> &'static str {
match self {
ServerLanguage::Rust => "rust",
ServerLanguage::Csharp => "csharp",
ServerLanguage::TypeScript => "typescript",
ServerLanguage::Cpp => "cpp",
}
}
fn from_str(s: &str) -> anyhow::Result<Option<Self>> {
match s.to_lowercase().as_str() {
"rust" => Ok(Some(ServerLanguage::Rust)),
"csharp" | "c#" => Ok(Some(ServerLanguage::Csharp)),
"typescript" => Ok(Some(ServerLanguage::TypeScript)),
"cpp" | "c++" | "cxx" => Ok(Some(ServerLanguage::Cpp)),
_ => Err(anyhow!("Unknown server language: {}", s)),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ClientLanguage {
Rust,
Csharp,
TypeScript,
}
impl ClientLanguage {
fn as_str(&self) -> &'static str {
match self {
ClientLanguage::Rust => "rust",
ClientLanguage::Csharp => "csharp",
ClientLanguage::TypeScript => "typescript",
}View on GitHub (pinned to fdd647dfac)