clockworklabs/SpacetimeDB · error · anyhow::Error

Cannot use generate-entry-specific arguments

Error message

Cannot use generate-entry-specific arguments ({}) when generating for multiple entries. Specify a database name to select a single target, or remove these arguments.

What it means

The generate-flavored multi-target guard: when spacetime.json declares multiple generate entries, CLI arguments marked generate-entry-specific are rejected because they cannot be applied to every entry. The message tells you to select a single entry via a database name or drop the arguments.

Solutions

  1. Pass the database name to select a single generate entry
  2. Remove the entry-specific CLI arguments for multi-entry runs
  3. Encode the per-entry options inside each generate entry in spacetime.json

Example fix

# before
spacetime generate --<entry-specific-arg> value
# with multiple generate entries in spacetime.json

# after
spacetime generate --database my-db --<entry-specific-arg> value
Defensive patterns

Strategy: validation

Validate before calling

// with multiple generate entries, require an explicit single target
if generate_entries.len() > 1 && database_name.is_none() {
    assert!(entry_specific_args.is_empty(), "pass --database or drop entry-specific args");
}

Try / catch

Catch the 'Cannot use generate-entry-specific arguments' bail, surface the hint (select one entry via database name), and re-run with a single target.

Prevention

When it happens

Trigger: Running `spacetime generate` with entry_count > 1 (multiple generate entries in config) while any generate-entry-specific CLI argument is present.

Common situations: Generating bindings for several languages or modules at once while passing per-entry options (output settings and the like) on the command line.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@eddf9f5014 (2026-08-20). Data as JSON: /api/errors/99b0c0657598a71a. Report an issue: GitHub.

Appendix: source

Thrown at crates/cli/src/spacetime_config.rs:579

    }

    /// Validate that generate-entry-specific CLI flags are not used when operating on multiple generate entries.
    pub fn validate_no_generate_entry_specific_cli_args(
        &self,
        command: &Command,
        matches: &ArgMatches,
        entry_count: usize,
    ) -> anyhow::Result<()> {
        if entry_count <= 1 {
            return Ok(());
        }

        let display_args = self.generate_entry_specific_cli_flags(command, matches);
        if display_args.is_empty() {
            return Ok(());
        }

        anyhow::bail!(
            "Cannot use generate-entry-specific arguments ({}) when generating for multiple entries. \
             Specify a database name to select a single target, or remove these arguments.",
            display_args.join(", "),
        );
    }

    /// Get the clap argument name for a config key.
    pub fn clap_arg_name_for<'a>(&'a self, config_name: &'a str) -> &'a str {
        self.config_to_clap
            .get(config_name)
            .map(|s| s.as_str())
            .unwrap_or(config_name)
    }
}

/// Configuration for a single key in the CommandConfig.
#[derive(Debug, Clone)]
pub struct Key {

View on GitHub (pinned to eddf9f5014)