{"record":{"id":"717dac3ef4cf25e1","repo":"linera-io/linera-protocol","slug":"incorrect-version-for-binary-name","errorCode":null,"errorMessage":"Incorrect version for binary {name}","messagePattern":"Incorrect version for binary (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"linera-base/src/command.rs","lineNumber":101,"sourceCode":"    let version_message = Command::new(&binary)\n        .arg(\"--version\")\n        .output()\n        .await\n        .with_context(|| {\n            format!(\n                \"Failed to execute and retrieve version from the binary {name} in directory {}\",\n                current_binary_parent.display()\n            )\n        })?\n        .stdout;\n    let version_message = String::from_utf8_lossy(&version_message);\n    let found_version = parse_version_message(&version_message);\n    if version != found_version {\n        error!(\"The binary {name} in directory {} should have version {version} (found {found_version}). \\\n                Consider using `cargo install {package} --version '{version}'` or `cargo build -p {package}`\",\n               current_binary_parent.display()\n        );\n        bail!(\"Incorrect version for binary {name}\");\n    }\n    debug!(\"{} has version {version}\", binary.display());\n\n    Ok(binary)\n}\n\n/// Obtains the version from the message.\npub fn parse_version_message(message: &str) -> String {\n    let mut lines = message.lines();\n    lines.next();\n    lines\n        .next()\n        .unwrap_or_default()\n        .trim()\n        .split(' ')\n        .next_back()\n        .expect(\"splitting strings gives non-empty lists\")\n        .to_string()","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-base/src/command.rs#L83-L119","documentation":"After resolve_binary_in_same_directory_as finds the sibling binary, it runs `<binary> --version` and requires the reported version to equal the current crate's version (v + CARGO_PKG_VERSION). A mismatch bails with 'Incorrect version for binary'. The check exists because Linera's processes talk to each other over RPC and must speak the same protocol version.","triggerScenarios":"The helper binary found next to the current executable is from a different build: a stale linera-proxy left in target/ or ~/.cargo/bin from an older install, or a workspace where only some crates were rebuilt after pulling new commits.","commonSituations":"Upgrading the repo and rebuilding partially, leaving old sibling binaries; docker images layering new binaries over old ones; multiple checkouts sharing a target dir; cargo install without --version after a release bump.","solutions":["Rebuild the whole workspace in one go (cargo build / make build) so all sibling binaries share the same version","Delete stale binaries from the directory (cargo clean or rm of the outdated files) and rebuild","With cargo install, pin the same version for all companion packages: cargo install <package> --version '<version>'"],"exampleFix":"# before\n# target/debug still contains an old linera-proxy\ncargo build -p linera-server && ./target/debug/linera-server ...  # Incorrect version for binary linera-proxy\n\n# after\ncargo clean -p linera-proxy && cargo build\n./target/debug/linera-server ...","handlingStrategy":"validation","validationCode":"async fn binary_version_matches(binary: &std::path::Path, expected: &str) -> bool {\n    let out = tokio::process::Command::new(binary).arg(\"--version\").output().await.unwrap();\n    linera_base::command::parse_version_message(&String::from_utf8_lossy(&out.stdout)) == expected\n}\nlet expected = format!(\"v{}\", env!(\"CARGO_PKG_VERSION\"));\nassert!(binary_version_matches(&binary, &expected).await, \"stale binary: {}\", binary.display());","typeGuard":null,"tryCatchPattern":"match linera_base::command::resolve_binary(NAME, PACKAGE).await {\n    Ok(path) => spawn(path),\n    Err(e) => eprintln!(\"{NAME} missing or wrong version: {e:#}; rebuild the workspace (cargo build)\"),\n}","preventionTips":["Rebuild the entire workspace in one cargo build invocation after pulling changes","cargo clean stale packages when binaries misbehave after an upgrade","Pin all cargo-installed Linera packages to one --version"],"tags":["tooling","versioning","process-spawn","build","environment"],"backgroundTag":"version-mismatch","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}