{"record":{"id":"147358534b75d0e5","repo":"clockworklabs/SpacetimeDB","slug":"no-matching-target-found-in-spacetime-json-for-the","errorCode":null,"errorMessage":"No matching target found in spacetime.json for the provided arguments. Use --no-config to ignore the config file.","messagePattern":"No matching target found in spacetime\\.json for the provided arguments\\. Use --no-config to ignore the config file\\.","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/publish.rs","lineNumber":516,"sourceCode":"            && args.contains_id(\"module_path\")\n            && let Some(module_path) = args.get_one::<PathBuf>(\"module_path\")\n        {\n            owned_loaded = find_and_load_with_env_from(env, module_path.clone())?;\n        }\n\n        owned_loaded.as_ref().inspect(|loaded| {\n            if !quiet_config {\n                for path in &loaded.loaded_files {\n                    println!(\"Using configuration from {}\", path.display());\n                }\n            }\n        })\n    };\n\n    let (using_config, publish_configs) = if let Some(loaded) = loaded_config_ref {\n        let filtered = get_filtered_publish_configs(&loaded.config, &cmd, &schema, args)?;\n        if filtered.is_empty() {\n            anyhow::bail!(\n                \"No matching target found in spacetime.json for the provided arguments. \\\n                 Use --no-config to ignore the config file.\"\n            );\n        }\n        (true, filtered)\n    } else {\n        (\n            false,\n            vec![CommandConfig::new(&schema, std::collections::HashMap::new(), args)?],\n        )\n    };\n\n    let clear_database = args\n        .get_one::<ClearMode>(\"clear-database\")\n        .copied()\n        .unwrap_or(ClearMode::Never);\n    let yes = yes_flags_from_args(args);\n    let environment_options = EnvironmentOptions::from_args(args)?;","sourceCodeStart":498,"sourceCodeEnd":534,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/eddf9f5014579a50d4b67630e28b6e15cad9c4af/crates/cli/src/subcommands/publish.rs#L498-L534","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before: publishes from a dir whose parent spacetime.json has no targets\nspacetime publish mydb\n# after\nspacetime publish mydb --no-config","handlingStrategy":"validation","validationCode":"# fail fast if the config that publish would load has no targets\nCFG=$(findup spacetime.json 2>/dev/null || true)\n[ -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'","typeGuard":null,"tryCatchPattern":"match publish_exec().await {\n    Err(e) if e.to_string().contains(\"No matching target found in spacetime.json\") => {\n        // retry once with --no-config, or locate and repair the config file\n    }\n    rest => rest,\n}","preventionTips":["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"],"tags":["spacetime-publish","spacetime-json","config","cli"],"backgroundTag":"config-target-not-found","analyzedSha":"eddf9f5014579a50d4b67630e28b6e15cad9c4af","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}