{"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":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/dev.rs","lineNumber":330,"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":312,"sourceCodeEnd":348,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/3653d2ed498fddbd83b7062aa6bf8970e18635ec/crates/cli/src/subcommands/dev.rs#L312-L348","documentation":"`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.","triggerScenarios":"spacetime.json contains a non-empty publish array and the command line includes --module-path (ValueSource::CommandLine).","commonSituations":"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.","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"],"exampleFix":"# before\nspacetime dev --module-path ./spacetimedb\n# spacetime.json has \"publish\": [ ... ]\n\n# after\nspacetime dev    # module paths come from the publish targets","handlingStrategy":"validation","validationCode":"// skip the flag when publish targets exist in spacetime.json\nlet has_publish_targets = !spacetime_json.publish.as_ref().map_or(false, Vec::is_empty);\nif has_publish_targets {\n    assert!(!cli_has_flag(\"--module-path\"), \"remove --module-path; publish targets own module paths\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["cli","dev","module-path","publish","spacetime-json"],"backgroundTag":"conflicting-cli-config-options","analyzedSha":"3653d2ed498fddbd83b7062aa6bf8970e18635ec","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}