clockworklabs/SpacetimeDB · error · anyhow::Error
Either --out-dir or --uproject-dir is required
Error message
Either --out-dir or --uproject-dir is required
What it means
When resolving the output directory for a generate run, the CLI tries four sources in order: --out-dir, --uproject-dir, then a per-language default (default_out_dir_for_language: 'src/module_bindings' for Rust/TypeScript, 'module_bindings' for C#, and None for UnrealCpp). If all are exhausted — only possible for a language with no default, i.e. unrealcpp — the run is rejected with 'Either --out-dir or --uproject-dir is required'. Note the uproject_dir lookup flattens resolution errors with .ok(), so an unresolvable uproject-dir path is silently treated as absent.
Solutions
- Pass --out-dir explicitly: `spacetime generate --lang unrealcpp --out-dir ./Generated`
- Or pass --uproject-dir, which doubles as the output location for unrealcpp
- For config-driven runs, add a resolvable `out-dir` (absolute, or relative to the spacetime.json directory) to the generate entry
Example fix
# before
spacetime generate --lang unrealcpp --bin-path module.wasm
# after
spacetime generate --lang unrealcpp --bin-path module.wasm --out-dir ~/Projects/MyGame/Plugins/SpacetimeDB/Source
# spacetime.json generate entry — after
# { "language": "unrealcpp", "bin-path": "target/wasm32-unknown-unknown/release/module.wasm",
# "out-dir": "../MyGame/Plugins/SpacetimeDB/Source" } Defensive patterns
Strategy: validation
Validate before calling
# unrealcpp has NO default out dir — require one explicitly:
: "${OUT_DIR:?unrealcpp needs --out-dir or --uproject-dir}"
spacetime generate --lang unrealcpp --out-dir "$OUT_DIR" "$@" Prevention
- Never assume a default output folder for unrealcpp; only rust/ts (src/module_bindings) and csharp (module_bindings) have defaults
- Use absolute or config-relative out-dir paths in spacetime.json; a relative path that fails to resolve is silently dropped
- Test generate configs in CI where a missing out-dir fails the build instead of a developer's machine
When it happens
Trigger: `spacetime generate --lang unrealcpp` with neither --out-dir nor --uproject-dir (typical when error 345 was bypassed via config-supplied uproject-dir that failed to resolve, or when generating unrealcpp from a spacetime.json entry lacking both keys).
Common situations: Non-interactive/CI generation for unrealcpp where the operator assumed a default output folder exists; spacetime.json generate entries copied from a Rust project (which never need out-dir because of the default) and switched to unrealcpp; a relative uproject-dir in config that fails to resolve against config_dir and is dropped by .ok().flatten().
Related errors
- --unreal-module-name is required for --lang unrealcpp
- --uproject-dir is required for --lang unrealcpp
- --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/470b45023d6225e4.
Report an issue: GitHub.
Appendix: source
Thrown at crates/cli/src/subcommands/generate.rs:384
println!(
"Detected client language '{}' from '{}'. If this is not correct, pass --lang or add a generate target in spacetime.json.",
language_cli_name(detected),
client_project_dir.display()
);
detected
}
};
let out_dir = command_config
.get_resolved_path("out_dir", config_dir)?
.or_else(|| {
command_config
.get_resolved_path("uproject_dir", config_dir)
.ok()
.flatten()
})
.or_else(|| default_out_dir_for_language(lang).map(|p| config_dir.map(|d| d.join(&p)).unwrap_or(p)))
.ok_or_else(|| anyhow::anyhow!("Either --out-dir or --uproject-dir is required"))?;
let include_private = command_config.get_one::<bool>("include_private")?.unwrap_or(false);
runs.push(GenerateRunConfig {
project_path,
wasm_file,
js_file,
lang,
namespace,
module_name,
module_prefix,
build_options,
dotnet_version,
out_dir,
include_private,
});
}
View on GitHub (pinned to eddf9f5014)