{"record":{"id":"2005f817cb1f182b","repo":"clockworklabs/SpacetimeDB","slug":"running-spacetime-version-from-a-target-directo","errorCode":null,"errorMessage":"running `spacetime version` from a target/ directory, but the spacetimedb-update\n             binary doesn't exist. try running `cargo build -p spacetimedb-update`","messagePattern":"running `spacetime version` from a target/ directory, but the spacetimedb-update\n             binary doesn't exist\\. try running `cargo build -p spacetimedb-update`","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/version.rs","lineNumber":32,"sourceCode":"/// Manage installed spacetime versions\n///\n/// Run `spacetime version --help` to see all options.\n#[derive(clap::Args)]\n#[command(disable_help_flag = true)]\nstruct Version {\n    /// The args to pass to spacetimedb-update\n    #[arg(allow_hyphen_values = true, num_args = 0..)]\n    args: Vec<OsString>,\n}\n\npub async fn exec(paths: &SpacetimePaths, root_dir: Option<&RootDir>, args: &ArgMatches) -> anyhow::Result<ExitCode> {\n    let args = args.get_many::<OsString>(\"args\").unwrap_or_default();\n    let bin_path;\n    let bin_path = if let Some(artifact_dir) = running_from_target_dir() {\n        let update_path = artifact_dir\n            .join(\"spacetimedb-update\")\n            .with_extension(std::env::consts::EXE_EXTENSION);\n        anyhow::ensure!(\n            update_path.exists(),\n            \"running `spacetime version` from a target/ directory, but the spacetimedb-update\n             binary doesn't exist. try running `cargo build -p spacetimedb-update`\"\n        );\n        bin_path = BinFile::from_path_unchecked(update_path);\n        &bin_path\n    } else {\n        &paths.cli_bin_file\n    };\n    let mut cmd = Command::new(bin_path);\n    if let Some(root_dir) = root_dir {\n        cmd.arg(\"--root-dir\").arg(root_dir);\n    }\n    cmd.arg(\"version\").args(args);\n    let applet = \"spacetimedb-update\";\n    #[cfg(unix)]\n    {\n        use std::os::unix::process::CommandExt;","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/subcommands/version.rs#L14-L50","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run `cargo build -p spacetimedb-update` so the sibling binary exists in the same target dir","Or build the whole workspace once (`cargo build`) to get all companion binaries","Or run the installed CLI (outside target/) instead of the dev artifact"],"exampleFix":"# before\ncargo run -p spacetimedb -- version    # spacetimedb-update doesn't exist\n# after\ncargo build -p spacetimedb-update\ncargo run -p spacetimedb -- version","handlingStrategy":"validation","validationCode":"# Before running version from a dev checkout, ensure the companion binary exists\ncargo build -p spacetimedb-update","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build the whole workspace once (`cargo build`) after cloning so companion binaries exist","In scripts, run the installed CLI rather than target/ artifacts when you only need the version"],"tags":["spacetimedb","version","dev-build","missing-binary","cargo"],"backgroundTag":"missing-companion-binary","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}