clockworklabs/SpacetimeDB · error · anyhow::Error
--uproject-dir is required for --lang unrealcpp
Error message
--uproject-dir is required for --lang unrealcpp
What it means
`spacetime generate --lang unrealcpp` produces an Unreal Engine C++ plugin that must live inside a .uproject-containing project, so the CLI validates Unreal-specific arguments up front. If the resolved uproject_dir is None (no --uproject-dir flag and nothing in the generate config), generation refuses to start with this focused error.
Solutions
- Pass the path to your Unreal project directory: `spacetime generate --lang unrealcpp --uproject-dir /path/to/MyProject`
- Or persist it in spacetime.json under the generate entry: `"uproject-dir": "../MyProject"`
- Also provide --unreal-module-name at the same time, since it is validated immediately after (error 346)
Example fix
# before spacetime generate --lang unrealcpp --bin-path module.wasm # after spacetime generate --lang unrealcpp --bin-path module.wasm \ --uproject-dir ~/Projects/MyGame --unreal-module-name MyGame
Defensive patterns
Strategy: validation
Validate before calling
#!/usr/bin/env bash
uproject="${UPROJECT_DIR:-}"
[ -n "$uproject" ] && [ -d "$uproject" ] || { echo '--uproject-dir <dir> required and must exist'; exit 2; }
spacetime generate --lang unrealcpp --uproject-dir "$uproject" --unreal-module-name "$MODULE_NAME" Prevention
- Wrap unrealcpp generation in a script that requires UPROJECT_DIR and MODULE_NAME env vars up front
- Store uproject-dir/module-name in the spacetime.json generate entry so manual invocations can't forget them
- Remember unrealcpp has stricter requirements than rust/ts/csharp — check args before invoking
When it happens
Trigger: Running `spacetime generate --lang unrealcpp` without `--uproject-dir` (and with no `uproject-dir` key in the spacetime.json generate config for this entry). The check runs before module-source validation so the missing Unreal argument is reported first.
Common situations: Copying a generate invocation from a Rust/TypeScript project where --uproject-dir doesn't exist; CI pipelines generating UE bindings against a workspace where the uproject path is passed via a variable that is empty; forgetting that unrealcpp has stricter requirements than other languages.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- --unreal-module-name is required for --lang unrealcpp
- Either --out-dir or --uproject-dir is required
- --namespace is only supported with --lang csharp
- Unknown client language
- Unknown server language
AI-assisted analysis of clockworklabs/SpacetimeDB@eddf9f5014 (2026-08-20).
Data as JSON: /api/errors/5f5880ad2967f15a.
Report an issue: GitHub.
Appendix: source
Thrown at crates/cli/src/subcommands/generate.rs:344
let namespace = command_config
.get_one::<String>("namespace")?
.unwrap_or_else(|| "SpacetimeDB.Types".to_string());
let module_name = command_config.get_one::<String>("unreal_module_name")?;
let module_prefix = command_config.get_one::<String>("module_prefix")?;
let build_options = command_config
.get_one::<String>("build_options")?
.unwrap_or_else(String::new);
let dotnet_version = if command_config.is_from_cli("dotnet_version") {
command_config.get_one::<u8>("dotnet_version")?
} else {
let dotnet_version = command_config.get_one::<String>("dotnet_version")?;
parse_optional_dotnet_version(dotnet_version.as_deref())?
};
// Validate Unreal-specific args first to preserve focused errors for this mode.
if requested_lang == Some(Language::UnrealCpp) {
if command_config.get_one::<PathBuf>("uproject_dir")?.is_none() {
return Err(anyhow::anyhow!("--uproject-dir is required for --lang unrealcpp"));
}
if module_name.is_none() {
return Err(anyhow::anyhow!("--unreal-module-name is required for --lang unrealcpp"));
}
}
// Validate module source path for source-based generation.
if wasm_file.is_none() && js_file.is_none() && !project_path.is_dir() {
anyhow::bail!(
"Could not find module source at '{}'. \
If this is not correct, pass --module-path or add module-path in spacetime.json. \
You can also pass --bin-path/--js-path to generate without building from source.",
project_path.display()
);
}
let lang = match requested_lang {
Some(lang) => lang,View on GitHub (pinned to eddf9f5014)