clockworklabs/SpacetimeDB · error · anyhow::Error

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

Error message

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

What it means

When the CLI detects it is running from a cargo `target/` artifact directory (a dev build via `cargo run`), `spacetime version` delegates to a sibling `spacetimedb-update` binary in the same artifact dir rather than the installed one. `anyhow::ensure!` fires when that sibling file does not exist, telling you to build it first.

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 524b4487d9)

Solutions

  1. Run `cargo build -p spacetimedb-update` so the sibling binary exists in the same target dir
  2. Or build the whole workspace once (`cargo build`) to get all companion binaries
  3. Or run the installed CLI (outside target/) instead of the dev artifact

Example fix

# before
cargo run -p spacetimedb -- version    # spacetimedb-update doesn't exist
# after
cargo build -p spacetimedb-update
cargo run -p spacetimedb -- version
Defensive patterns

Strategy: validation

Validate before calling

# Before running version from a dev checkout, ensure the companion binary exists
cargo build -p spacetimedb-update

Prevention

When it happens

Trigger: Running `cargo run -p spacetimedb -- version` (or the built binary directly from `target/...`) without having built the `spacetimedb-update` package, so `target/<profile>/spacetimedb-update` is missing.

Common situations: Fresh clone where only the main CLI crate was built; selective `cargo build -p spacetimedb-cli` workflows; CI invoking the uninstalled dev binary to print its version.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16). Data as JSON: /api/errors/2005f817cb1f182b. Report an issue: GitHub.