clockworklabs/SpacetimeDB · error

the following required arguments were not provided

Error message

the following required arguments were not provided:
  <database>

Usage: {}

What it means

resolve_database_arg (crates/cli/src/subcommands/db_arg_resolution.rs:156) is used by commands with a dedicated optional <database> argument (logs, delete). When no config targets exist (--no-config or no spacetime.json in scope) and raw_database is None, there is nothing to fall back on, so it raises this usage error naming <database> and the command's usage line.

Solutions

  1. Pass the database explicitly: `spacetime logs <database>` / `spacetime delete <database>`.
  2. Run the command from a directory whose spacetime.json declares the database target, so the argument is implied.
  3. In scripts, default the argument from an environment variable (e.g. "${SPACETIME_DB:?database required}") to fail fast with your own message.

Example fix

# before: no config, no database
spacetime logs
# after
spacetime logs my-db --no-config
Defensive patterns

Strategy: validation

Validate before calling

# For logs/delete outside a project, require the database up front:
DB="${1:-${SPACETIME_DB:-}}"
[ -n "$DB" ] || { echo "missing <database>; set SPACETIME_DB or pass it as the first arg" >&2; exit 2; }
spacetime logs "$DB" --no-config

Prevention

When it happens

Trigger: Running `spacetime logs` or `spacetime delete` outside a project (no spacetime.json) without a database argument; running them with --no-config and omitting the database; a spacetime.json that exists but declares no database targets.

Common situations: Ad-hoc server inspection from a random directory; cleanup scripts that assumed the project config would supply the database; fresh clones where the config file is generated later.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

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

    };
    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 fdd647dfac)