clockworklabs/SpacetimeDB · error

`--module-path`, `--project-path`, and `--module-bindings-pa

Error message

`--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.

What it means

Companion guard to the publish-target check: `spacetime dev` bails when `spacetime.json` defines generate targets AND any of `--module-path`, `--project-path`, or `--module-bindings-path` was supplied on the command line. Generate targets own their path configuration, so CLI path flags are rejected to avoid silently changing where code/bindings get written. Only true command-line values count; defaults and env-var sources do not trigger it.

Source

Thrown at crates/cli/src/subcommands/dev.rs:333

        .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"))
        .map(|name| {
            if args.get_one::<String>("database-flag").is_some() {
                println!(
                    "{} {}",
                    "Warning:".yellow().bold(),
                    "--database flag is deprecated. Use positional argument instead: spacetime dev <database>".dimmed()
                );
            }
            name.clone()

View on GitHub (pinned to 524b4487d9)

Solutions

  1. Remove `--module-path`, `--project-path`, and `--module-bindings-path` from the command
  2. Configure paths inside the generate targets in `spacetime.json` instead
  3. Or remove the generate targets from config if you want flag-driven behavior

Example fix

# before
spacetime dev --project-path . --module-bindings-path generated
# (spacetime.json has "generate": [...])
# after
spacetime dev  # paths come from generate targets in spacetime.json
Defensive patterns

Strategy: validation

Validate before calling

# Skip path flags whenever generate targets exist
if jq -e '.generate | length > 0' spacetime.json >/dev/null 2>&1; then
  spacetime dev            # paths come from config
else
  spacetime dev --project-path . --module-bindings-path generated
fi

Prevention

When it happens

Trigger: Running `spacetime dev --project-path .` or `--module-bindings-path gen` when `spacetime.json` has a non-empty `generate` array.

Common situations: Enabling code generation in config then reusing an old dev command that still passes path flags; CI scripts parameterized with explicit paths; migrating a project from flag-driven to config-driven layouts without cleaning up the flags.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16). Data as JSON: /api/errors/560520c17a921792. Report an issue: GitHub.