linera-io/linera-protocol · error

Incorrect version for binary {name}

Error message

Incorrect version for binary {name}

What it means

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.

Source

Thrown at linera-base/src/command.rs:101

    let version_message = Command::new(&binary)
        .arg("--version")
        .output()
        .await
        .with_context(|| {
            format!(
                "Failed to execute and retrieve version from the binary {name} in directory {}",
                current_binary_parent.display()
            )
        })?
        .stdout;
    let version_message = String::from_utf8_lossy(&version_message);
    let found_version = parse_version_message(&version_message);
    if version != found_version {
        error!("The binary {name} in directory {} should have version {version} (found {found_version}). \
                Consider using `cargo install {package} --version '{version}'` or `cargo build -p {package}`",
               current_binary_parent.display()
        );
        bail!("Incorrect version for binary {name}");
    }
    debug!("{} has version {version}", binary.display());

    Ok(binary)
}

/// Obtains the version from the message.
pub fn parse_version_message(message: &str) -> String {
    let mut lines = message.lines();
    lines.next();
    lines
        .next()
        .unwrap_or_default()
        .trim()
        .split(' ')
        .next_back()
        .expect("splitting strings gives non-empty lists")
        .to_string()

View on GitHub (pinned to 6c226ddcb3)

Solutions

  1. Rebuild the whole workspace in one go (cargo build / make build) so all sibling binaries share the same version
  2. Delete stale binaries from the directory (cargo clean or rm of the outdated files) and rebuild
  3. With cargo install, pin the same version for all companion packages: cargo install <package> --version '<version>'

Example fix

# before
# target/debug still contains an old linera-proxy
cargo build -p linera-server && ./target/debug/linera-server ...  # Incorrect version for binary linera-proxy

# after
cargo clean -p linera-proxy && cargo build
./target/debug/linera-server ...
Defensive patterns

Strategy: validation

Validate before calling

async fn binary_version_matches(binary: &std::path::Path, expected: &str) -> bool {
    let out = tokio::process::Command::new(binary).arg("--version").output().await.unwrap();
    linera_base::command::parse_version_message(&String::from_utf8_lossy(&out.stdout)) == expected
}
let expected = format!("v{}", env!("CARGO_PKG_VERSION"));
assert!(binary_version_matches(&binary, &expected).await, "stale binary: {}", binary.display());

Try / catch

match linera_base::command::resolve_binary(NAME, PACKAGE).await {
    Ok(path) => spawn(path),
    Err(e) => eprintln!("{NAME} missing or wrong version: {e:#}; rebuild the workspace (cargo build)"),
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of linera-io/linera-protocol@6c226ddcb3 (2026-08-22). Data as JSON: /api/errors/717dac3ef4cf25e1. Report an issue: GitHub.