clockworklabs/SpacetimeDB · error

the following required arguments were not provided: <datab

Error message

the following required arguments were not provided:
  <database>

Usage: {}

What it means

resolve_database_arg's no-config branch: the command needs a database, no config targets exist to supply a default, and raw_database is None (no positional and no -d/--database value), so the synthetic clap error demands <database> with the caller's usage string.

Source

Thrown at crates/cli/src/subcommands/db_arg_resolution.rs:156

    };
    if raw_parts.len() < 2 {
        return Err(require_arg(required_arg_name));
    }

    Ok(ResolvedDbArgs {
        database: db.clone(),
        server: target.server.clone(),
        remaining_args: raw_parts[1..].to_vec(),
    })
}

pub(crate) fn resolve_database_arg(
    raw_database: Option<&str>,
    config_targets: Option<&[ConfigDbTarget]>,
    usage: &str,
) -> anyhow::Result<ResolvedDbArgs> {
    let require_database = || {
        anyhow::anyhow!(
            "the following required arguments were not provided:\n  <database>\n\nUsage: {}",
            usage
        )
    };

    let Some(config_targets) = config_targets else {
        let database = raw_database.ok_or_else(require_database)?;
        return Ok(ResolvedDbArgs {
            database: database.to_string(),
            server: None,
            remaining_args: vec![],
        });
    };

    if config_targets.len() == 1 {
        let target = &config_targets[0];
        if let Some(db) = raw_database
            && db != target.database

View on GitHub (pinned to 524b4487d9)

Solutions

  1. Pass the database name as the positional (or via the -d/--database flag) as shown in the Usage line
  2. cd into the project directory containing spacetime.json so its default applies
  3. Remove --no-config if project defaults were intended

Example fix

# before
spacetime publish

# after
spacetime publish mydb
Defensive patterns

Strategy: validation

Validate before calling

# Require a database (positional or -d) when no project config is present
DB="${1:-$SPACETIME_DB}"
[ -n "$DB" ] || { echo 'database required (no spacetime.json found)' >&2; exit 2; }
spacetime publish "$DB"

Type guard

fn db_arg_provided(positional: Option<&str>, flag: Option<&str>) -> bool {
    positional.is_some() || flag.is_some()
}

Try / catch

if ! spacetime publish $EXTRA; then
  # on 'required arguments were not provided: <database>', re-run with the configured default:
  spacetime publish "$(jq -r '.databases[0].database' spacetime.json)"
fi

Prevention

When it happens

Trigger: Running a database-scoped command (e.g. `spacetime publish` with no database argument) outside a project directory, or with --no-config, so nothing can fill in the database.

Common situations: First commands in a fresh clone before entering the project; CI steps that run from an artifacts directory; assuming the CLI remembers a previously used database (it doesn't — the default comes only from project config).

Related errors


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