{"record":{"id":"f157785b20f21385","repo":"clockworklabs/SpacetimeDB","slug":"module-path-cannot-be-used-when-spacetime-jso","errorCode":null,"errorMessage":"`--module-path` cannot be used when `spacetime.json` contains publish targets. Remove `--module-path` or run without publish targets in config.","messagePattern":"`--module-path` cannot be used when `spacetime\\.json` contains publish targets\\. Remove `--module-path` or run without publish targets in config\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/dev.rs","lineNumber":324,"sourceCode":"    }\n\n    let spacetime_config = loaded_config.as_ref().map(|lc| &lc.config);\n    // A config has publish targets if it has a \"database\" field or children\n    let has_publish_targets_in_config = spacetime_config\n        .map(|c| c.additional_fields.contains_key(\"database\") || c.children.is_some())\n        .unwrap_or(false);\n    let has_generate_targets_in_config = spacetime_config\n        .and_then(|c| c.generate.as_ref())\n        .map(|g| !g.is_empty())\n        .unwrap_or(false);\n\n    let module_path_from_cli_flag = args.value_source(\"module-path\") == Some(ValueSource::CommandLine);\n    let project_path_from_cli_flag = args.value_source(\"project-path\") == Some(ValueSource::CommandLine);\n    let module_bindings_path_from_cli_flag =\n        args.value_source(\"module-bindings-path\") == Some(ValueSource::CommandLine);\n\n    if has_publish_targets_in_config && module_path_from_cli_flag {\n        anyhow::bail!(\n            \"`--module-path` cannot be used when `spacetime.json` contains publish targets. \\\n             Remove `--module-path` or run without publish targets in config.\"\n        );\n    }\n\n    if has_generate_targets_in_config\n        && (module_path_from_cli_flag || project_path_from_cli_flag || module_bindings_path_from_cli_flag)\n    {\n        anyhow::bail!(\n            \"`--module-path`, `--project-path`, and `--module-bindings-path` cannot be used when \\\n             `spacetime.json` contains generate targets. Remove these flags or remove generate targets from config.\"\n        );\n    }\n\n    // Fetch the database name if it was passed through a CLI arg\n    let database_name_from_cli: Option<String> = args\n        .get_one::<String>(\"database\")\n        .or_else(|| args.get_one::<String>(\"database-flag\"))","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/subcommands/dev.rs#L306-L342","documentation":"`spacetime dev` refuses to mix an explicit `--module-path` CLI flag with a `spacetime.json` that defines publish targets. Publish targets each carry their own `module_path`, so a CLI `--module-path` would be ambiguous — it is only checked when the flag genuinely came from the command line (`ValueSource::CommandLine`), so having the same value in an env var or default does not trigger it.","triggerScenarios":"Running `spacetime dev --module-path ./src` when `spacetime.json` has a non-empty `publish` array (even a single target).","commonSituations":"Adding publish targets to config on a project that previously used `--module-path` habitually; copy-pasting a dev command from docs into a multi-target repo; wrapper scripts that always pass `--module-path`.","solutions":["Drop `--module-path` and set `module_path` on each publish target in `spacetime.json`","Or temporarily remove/disable the publish targets from `spacetime.json` if the flag must stay","Update wrapper scripts/aliases to not pass `--module-path` in publish-target projects"],"exampleFix":"# before\nspacetime dev --module-path ./spacetimedb\n# (spacetime.json has \"publish\": [{ \"database\": \"db\", \"module_path\": \"./spacetimedb\" }])\n# after\nspacetime dev","handlingStrategy":"validation","validationCode":"# Only pass --module-path when there are no publish targets\nif jq -e '.publish | length > 0' spacetime.json >/dev/null 2>&1; then\n  spacetime dev\nelse\n  spacetime dev --module-path ./spacetimedb\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick one source of truth for module paths: config OR flags, never both","Audit wrapper scripts when adding publish targets to spacetime.json"],"tags":["cli","configuration","flag-conflict","spacetimedb"],"backgroundTag":"config-flag-conflict","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}