clockworklabs/SpacetimeDB · error
Database ' ' is not in the config file. If you want to run…
Error message
Database '{}' is not in the config file. If you want to run against a database outside of the current project, pass --no-config. What it means
The single-target variant of unknown_database_error (crates/cli/src/subcommands/db_arg_resolution.rs:51): the project's spacetime.json defines exactly one database target, and the first positional argument of an ambiguous-arg command (call/subscribe/describe) does not equal that configured name. Because these commands cannot tell a database name from their own first argument, there is no auto-fallthrough and the mismatch is rejected with a pointer to --no-config.
Solutions
- Use the configured database's exact name (shown in the error) as the first positional argument.
- Run without positional ambiguity by relying on the single target: `spacetime call <function_name> <args>` - the database is implied.
- Pass --no-config to treat the first argument as an ad-hoc database outside the project: `spacetime call <db> <fn> <args> --no-config`.
Example fix
# before: 'myfn' != configured database 'foo' spacetime call myfn 1 # after: rely on the single configured target spacetime call myfn 1 # db resolved from config # or bypass config spacetime call other-db myfn 1 --no-config
Defensive patterns
Strategy: validation
Validate before calling
# Single-target project: either omit the db (config implies it) or match the configured name.
configdb=$(jq -r '.databases | to_entries[0].value.database' spacetime.json 2>/dev/null)
[ -z "$configdb" ] || [ "$1" = "$configdb" ] || [ $# -eq 0 ] || { echo "use '$configdb' or pass --no-config" >&2; exit 2; } Prevention
- After renaming a database, update every script that names it, or drop the name and let the single config target imply it.
- Run commands from the project root so the intended spacetime.json is the one discovered.
- Use --no-config consciously for out-of-project databases instead of hoping a mismatched name falls through.
When it happens
Trigger: Running `spacetime call myfn 1` where the single configured target's database is `foo` - 'myfn' is not 'foo', so the resolver refuses to guess whether myfn is a database or a reducer name; renaming the database in spacetime.json but keeping old scripts; copy-pasting a command between projects.
Common situations: Renamed or re-published databases under new names while scripts still pass the old one; multiple projects with different db names sharing scripts; onboarding examples run in a configured project directory.
Related errors
- Multiple databases found in config
- Failed to parse config file
- Unable to parse invalid saved server fingerprint as ECDSA…
- Cannot extract accessor name from query
- Cannot extract table name from query
AI-assisted analysis of clockworklabs/SpacetimeDB@fdd647dfac (2026-08-20).
Data as JSON: /api/errors/38ee52647ddb0c6e.
Report an issue: GitHub.
Appendix: source
Thrown at crates/cli/src/subcommands/db_arg_resolution.rs:55
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct ResolvedDbArgs {
pub database: String,
pub server: Option<String>,
pub remaining_args: Vec<String>,
}
/// Build an error for when the first positional arg doesn't match any configured database target.
fn unknown_database_error(db: &str, config_targets: &[ConfigDbTarget]) -> anyhow::Error {
let known: Vec<&str> = config_targets.iter().map(|t| t.database.as_str()).collect();
if known.len() > 1 {
anyhow::anyhow!(
"Multiple databases found in config: {}. Please specify which database to use, \
or pass --no-config to use '{}' directly.",
known.join(", "),
db
)
} else {
anyhow::anyhow!(
"Database '{}' is not in the config file. \
If you want to run against a database outside of the current project, pass --no-config.",
db
)
}
}
pub(crate) fn load_config_db_targets(no_config: bool) -> anyhow::Result<Option<Vec<ConfigDbTarget>>> {
if no_config {
return Ok(None);
}
Ok(find_and_load_with_env(None)?
.map(|loaded| {
loaded
.config
.collect_all_targets_with_inheritance()
.iter()View on GitHub (pinned to fdd647dfac)