clockworklabs/SpacetimeDB · error · anyhow::Error

running `spacetime version` from a target/ directory, but…

Error message

running `spacetime version` from a target/ directory, but the spacetimedb-update\n             binary doesn't exist. try running `cargo build -p spacetimedb-update`

What it means

`spacetime version` detected it is running from a cargo target/ directory and therefore proxies to the sibling spacetimedb-update binary, but that binary does not exist in the same artifact directory. In dev builds the version/self-update machinery lives in the separate spacetimedb-update package, which must be built alongside the CLI.

Solutions

  1. Build the companion binary with the same profile: `cargo build -p spacetimedb-update`
  2. Or let cargo build everything: `cargo build -p spacetimedb -p spacetimedb-update` before running from target/
  3. If you meant to use a released install, invoke the installed `spacetime` binary instead of the one in target/

Example fix

# before
spacetime version   # running target/debug/spacetime

# after
cargo build -p spacetimedb-update && ./target/debug/spacetime version
Defensive patterns

Strategy: validation

Validate before calling

# bash: preflight both binaries when running from target/
[[ -x target/debug/spacetimedb && -x target/debug/spacetimedb-update ]] \
  || cargo build -p spacetimedb -p spacetimedb-update
target/debug/spacetime version

Prevention

When it happens

Trigger: Running the CLI binary directly from target/debug or target/release (or `cargo run -p spacetimedb -- version`) when `cargo build -p spacetimedb-update` has not been run for the same profile.

Common situations: Contributors hacking on the CLI repo; partial builds that only compiled the cli crate; CI jobs that build only the main binary.

Related errors


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

Appendix: source

Thrown at crates/cli/src/subcommands/version.rs:32

/// Manage installed spacetime versions
///
/// Run `spacetime version --help` to see all options.
#[derive(clap::Args)]
#[command(disable_help_flag = true)]
struct Version {
    /// The args to pass to spacetimedb-update
    #[arg(allow_hyphen_values = true, num_args = 0..)]
    args: Vec<OsString>,
}

pub async fn exec(paths: &SpacetimePaths, root_dir: Option<&RootDir>, args: &ArgMatches) -> anyhow::Result<ExitCode> {
    let args = args.get_many::<OsString>("args").unwrap_or_default();
    let bin_path;
    let bin_path = if let Some(artifact_dir) = running_from_target_dir() {
        let update_path = artifact_dir
            .join("spacetimedb-update")
            .with_extension(std::env::consts::EXE_EXTENSION);
        anyhow::ensure!(
            update_path.exists(),
            "running `spacetime version` from a target/ directory, but the spacetimedb-update
             binary doesn't exist. try running `cargo build -p spacetimedb-update`"
        );
        bin_path = BinFile::from_path_unchecked(update_path);
        &bin_path
    } else {
        &paths.cli_bin_file
    };
    let mut cmd = Command::new(bin_path);
    if let Some(root_dir) = root_dir {
        cmd.arg("--root-dir").arg(root_dir);
    }
    cmd.arg("version").args(args);
    let applet = "spacetimedb-update";
    #[cfg(unix)]
    {
        use std::os::unix::process::CommandExt;

View on GitHub (pinned to 6dee26c6ef)