clockworklabs/SpacetimeDB · error · anyhow::Error
Could not find module source at '{}'. If this is not correct
Error message
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, What it means
When neither `--bin-path` nor `--js-path` is supplied, `spacetime generate` builds your module from source, so the module directory (resolved from `--module-path`, the spacetime.json `module-path` field, or a default location) must exist and be a directory. If it doesn't, generate aborts before invoking any build toolchain. Passing a prebuilt artifact path skips this check entirely.
Source
Thrown at crates/cli/src/subcommands/generate.rs:354
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,
None => {
let client_project_dir = config_dir.unwrap_or_else(|| Path::new("."));
let detected = detect_default_language(client_project_dir)?;
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()
);
detectedView on GitHub (pinned to 524b4487d9)
Solutions
- Run from the project root that contains the module directory, or pass `--module-path path/to/module`
- Set `"module-path"` on the target in spacetime.json
- Skip the build with `--bin-path target/wasm32-unknown-unknown/release/module.wasm` (or `--js-path` for TypeScript modules)
- Check the path for typos and case sensitivity
Example fix
# before — fails: ./module does not exist spacetime generate # after — build from source elsewhere spacetime generate --module-path crates/server-module # after — no build, use prebuilt wasm spacetime generate --bin-path target/wasm32-unknown-unknown/release/module.wasm
Defensive patterns
Strategy: validation
Validate before calling
# Before generate-from-source, verify the module dir:
MODULE_DIR="${MODULE_PATH:-module}"
if [[ -z "$BIN_PATH" && -z "$JS_PATH" && ! -d "$MODULE_DIR" ]]; then
echo "module source '$MODULE_DIR' missing — pass --module-path or --bin-path" >&2
exit 2
fi
spacetime generate Try / catch
#!/usr/bin/env bash
if ! spacetime generate 2>err.log; then
if grep -q "Could not find module source" err.log; then
# fall back to the last known-good prebuilt wasm instead of failing the pipeline
spacetime generate --bin-path "$PREBUILT_WASM" || exit 1
else
cat err.log >&2; exit 1
fi
fi Prevention
- Pin `module-path` in spacetime.json so generate works from any working directory
- In CI, either check out the module source or pass an artifact via --bin-path/--js-path
- Verify the module directory exists in a preflight step of build scripts
When it happens
Trigger: `spacetime generate` in a repo where the module source directory doesn't exist at the resolved path; a typo'd `--module-path`; having only a prebuilt module.wasm/module.js but not passing `--bin-path`/`--js-path`.
Common situations: Running generate at repo root while the module lives under `crates/module` or similar; renamed module folder; CI checkouts that skip the module directory; attempting offline generation without a toolchain but forgetting the prebuilt flags.
Related errors
- Module directory does not exist: '{}'. Check your --module-p
- Fatal Error: path {} exists but is not a directory.
- Fatal Error: path {} does not exist.
- Could not find a SpacetimeDB module in spacetimedb/ or the c
- Cannot continue without a module path.
AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16).
Data as JSON: /api/errors/0a40187f97442442.
Report an issue: GitHub.