{"record":{"id":"a4db2a1da7eab918","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":"exception","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/6dee26c6efc2856793e12b148a59742964f5d783/crates/cli/src/subcommands/version.rs#L14-L50","documentation":"`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.","triggerScenarios":"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.","commonSituations":"Contributors hacking on the CLI repo; partial builds that only compiled the cli crate; CI jobs that build only the main binary.","solutions":["Build the companion binary with the same profile: `cargo build -p spacetimedb-update`","Or let cargo build everything: `cargo build -p spacetimedb -p spacetimedb-update` before running from target/","If you meant to use a released install, invoke the installed `spacetime` binary instead of the one in target/"],"exampleFix":"# before\nspacetime version   # running target/debug/spacetime\n\n# after\ncargo build -p spacetimedb-update && ./target/debug/spacetime version","handlingStrategy":"validation","validationCode":"# bash: preflight both binaries when running from target/\n[[ -x target/debug/spacetimedb && -x target/debug/spacetimedb-update ]] \\\n  || cargo build -p spacetimedb -p spacetimedb-update\ntarget/debug/spacetime version","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build the cli and update crates together in dev scripts","In CI, build the workspace (`cargo build --workspace` or both -p flags) before invoking target/ binaries"],"tags":["build","cli","dev-environment"],"backgroundTag":"missing-companion-binary","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}