clockworklabs/SpacetimeDB · error · anyhow::Error
No matching target found in spacetime.json for the provided…
Error message
No matching target found in spacetime.json for the provided arguments. Use --no-config to ignore the config file.
What it means
publish loads spacetime.json from the current directory (or ancestors) and asks it for publish targets; if the loaded config yields zero targets, publish refuses to guess and suggests --no-config. Note the database-name mismatch case has its own error — this one fires when the config file exists but defines no usable targets at all.
Solutions
- Inspect the printed 'Using configuration from <path>' line to find which spacetime.json was loaded
- Fix that file so it defines at least one valid target with a `database` field (check table/section names against the docs)
- Bypass config for this run: `spacetime publish --no-config <db>`
- Delete or rename the stray spacetime.json if it was inherited from a parent directory
Example fix
# before: publishes from a dir whose parent spacetime.json has no targets spacetime publish mydb # after spacetime publish mydb --no-config
Defensive patterns
Strategy: validation
Validate before calling
# fail fast if the config that publish would load has no targets
CFG=$(findup spacetime.json 2>/dev/null || true)
[ -n "$CFG" ] && [ -z "$(jq -r '.targets // {} | to_entries[] | select(.value.database != null) | .key' "$CFG" 2>/dev/null)" ] && echo 'config has no targets: use --no-config or fix it' Try / catch
match publish_exec().await {
Err(e) if e.to_string().contains("No matching target found in spacetime.json") => {
// retry once with --no-config, or locate and repair the config file
}
rest => rest,
} Prevention
- Run publish from the directory that owns the spacetime.json you expect; check the 'Using configuration from' line
- Validate target tables have a `database` field after hand edits
- Use --no-config in scripts that must not inherit ambient config
When it happens
Trigger: A spacetime.json present but missing/empty targets (e.g. only other sections, or target tables misnamed so collect_all_targets returns nothing); running publish in a subdirectory that unexpectedly inherits a parent's spacetime.json; config half-written by an interrupted init.
Common situations: Hand-authored spacetime.json with wrong table names; monorepos where a root spacetime.json is picked up from a nested package; stale config files from other tools named spacetime.json.
Related errors
- No database target matches
- database is a required field in publish config
- Aborted.
- Aborting because major version upgrade was not accepted.
- Cannot use generate-entry-specific arguments
AI-assisted analysis of clockworklabs/SpacetimeDB@eddf9f5014 (2026-08-20).
Data as JSON: /api/errors/147358534b75d0e5.
Report an issue: GitHub.
Appendix: source
Thrown at crates/cli/src/subcommands/publish.rs:516
&& args.contains_id("module_path")
&& let Some(module_path) = args.get_one::<PathBuf>("module_path")
{
owned_loaded = find_and_load_with_env_from(env, module_path.clone())?;
}
owned_loaded.as_ref().inspect(|loaded| {
if !quiet_config {
for path in &loaded.loaded_files {
println!("Using configuration from {}", path.display());
}
}
})
};
let (using_config, publish_configs) = if let Some(loaded) = loaded_config_ref {
let filtered = get_filtered_publish_configs(&loaded.config, &cmd, &schema, args)?;
if filtered.is_empty() {
anyhow::bail!(
"No matching target found in spacetime.json for the provided arguments. \
Use --no-config to ignore the config file."
);
}
(true, filtered)
} else {
(
false,
vec![CommandConfig::new(&schema, std::collections::HashMap::new(), args)?],
)
};
let clear_database = args
.get_one::<ClearMode>("clear-database")
.copied()
.unwrap_or(ClearMode::Never);
let yes = yes_flags_from_args(args);
let environment_options = EnvironmentOptions::from_args(args)?;View on GitHub (pinned to eddf9f5014)