clockworklabs/SpacetimeDB · error · anyhow::Error
`--module-path` cannot be used when `spacetime.json`…
Error message
`--module-path` cannot be used when `spacetime.json` contains publish targets. Remove `--module-path` or run without publish targets in config.
What it means
`spacetime dev` refuses to combine a CLI-provided --module-path with a spacetime.json that declares publish targets: with multiple publish targets there is no single module path, so the flag would be ambiguous. Only a flag whose value source is the command line triggers the check; config-provided paths are fine.
Solutions
- Drop --module-path and let the publish targets drive the module paths
- Remove the publish targets from spacetime.json if you truly want the single-path workflow
- Set module paths per target inside spacetime.json
Example fix
# before spacetime dev --module-path ./spacetimedb # spacetime.json has "publish": [ ... ] # after spacetime dev # module paths come from the publish targets
Defensive patterns
Strategy: validation
Validate before calling
// skip the flag when publish targets exist in spacetime.json
let has_publish_targets = !spacetime_json.publish.as_ref().map_or(false, Vec::is_empty);
if has_publish_targets {
assert!(!cli_has_flag("--module-path"), "remove --module-path; publish targets own module paths");
} Prevention
- Move module paths into per-target spacetime.json entries before adopting multi-target configs
- Audit wrapper scripts for stale --module-path flags after config migrations
When it happens
Trigger: spacetime.json contains a non-empty publish array and the command line includes --module-path (ValueSource::CommandLine).
Common situations: Converting a legacy single-module project whose scripts pass --module-path to the multi-target spacetime.json format; leftover flags in shell aliases or Makefiles.
Related errors
- Aborted.
- Cannot continue without a module path.
- Cannot use module-specific arguments
- database is a required field in publish config
- Missing loaded config directory
AI-assisted analysis of clockworklabs/SpacetimeDB@3653d2ed49 (2026-08-20).
Data as JSON: /api/errors/f157785b20f21385.
Report an issue: GitHub.
Appendix: source
Thrown at crates/cli/src/subcommands/dev.rs:330
}
let spacetime_config = loaded_config.as_ref().map(|lc| &lc.config);
// A config has publish targets if it has a "database" field or children
let has_publish_targets_in_config = spacetime_config
.map(|c| c.additional_fields.contains_key("database") || c.children.is_some())
.unwrap_or(false);
let has_generate_targets_in_config = spacetime_config
.and_then(|c| c.generate.as_ref())
.map(|g| !g.is_empty())
.unwrap_or(false);
let module_path_from_cli_flag = args.value_source("module-path") == Some(ValueSource::CommandLine);
let project_path_from_cli_flag = args.value_source("project-path") == Some(ValueSource::CommandLine);
let module_bindings_path_from_cli_flag =
args.value_source("module-bindings-path") == Some(ValueSource::CommandLine);
if has_publish_targets_in_config && module_path_from_cli_flag {
anyhow::bail!(
"`--module-path` cannot be used when `spacetime.json` contains publish targets. \
Remove `--module-path` or run without publish targets in config."
);
}
if has_generate_targets_in_config
&& (module_path_from_cli_flag || project_path_from_cli_flag || module_bindings_path_from_cli_flag)
{
anyhow::bail!(
"`--module-path`, `--project-path`, and `--module-bindings-path` cannot be used when \
`spacetime.json` contains generate targets. Remove these flags or remove generate targets from config."
);
}
// Fetch the database name if it was passed through a CLI arg
let database_name_from_cli: Option<String> = args
.get_one::<String>("database")
.or_else(|| args.get_one::<String>("database-flag"))View on GitHub (pinned to 3653d2ed49)