AlexsJones/llmfit · error · RuntimeError

Binary version mismatch: binary at

Error message

Binary version mismatch: binary at {bin_path} reports {binary_version!r} but Cargo.toml (or LLMFIT_VERSION) says {expected_version!r}. Run 'make build' to recompile.

What it means

Raised by _check_binary_version() when the binary executes and reports a version that differs from the package version resolved from Cargo.toml (or the LLMFIT_VERSION override). This is a staleness guard: it prevents packaging a binary compiled before a version bump, or pairing an overridden package version with an unmodified binary.

Solutions

  1. Recompile: `make build` (or `cargo build --release --target <triple>` for standard wheels), then rebuild the wheel
  2. If LLMFIT_VERSION is set, verify it matches what the binary reports: `./target/release/llmfit --version` vs `echo $LLMFIT_VERSION` — unset the override if it is stale
  3. In CI, always run the cargo build step after any step that touches Cargo.toml or exports LLMFIT_VERSION, and avoid caching target/ across version bumps

Example fix

# before
# Cargo.toml bumped to 0.9.9, binary still from 0.9.8
uv build  # RuntimeError: Binary version mismatch

# after
cargo build --release --target x86_64-unknown-linux-gnu
uv build
Defensive patterns

Strategy: validation

Validate before calling

import os, re, subprocess, tomllib
expected = os.environ.get("LLMFIT_VERSION") or tomllib.load(open("Cargo.toml", "rb"))["workspace"]["package"]["version"]
out = subprocess.run(["./target/release/llmfit", "--version"], capture_output=True, text=True, timeout=5).stdout.strip()
actual = re.fullmatch(r"llmfit v?(\d+\.\d+\.\d+)", out).group(1)
if actual != expected:
    raise SystemExit(f"stale binary {actual} vs expected {expected} — recompile before building the wheel")

Try / catch

try:
    hook._check_binary_version(bin_path, pypi_version)
except RuntimeError as e:
    raise SystemExit(f"stale artifact: {e}")

Prevention

When it happens

Trigger: Bumping [workspace.package].version in Cargo.toml and running `uv build` without recompiling; exporting LLMFIT_VERSION=0.9.8 for a release while the local binary still reports 0.9.7; a CI cache that restores an old target/ directory after the version bump commit.

Common situations: Release flows that set the version via env var in one job and reuse a Rust build artifact from another job; developers who bump versions in Cargo.toml during development and forget `make build`.

Related errors


AI-assisted analysis of AlexsJones/llmfit@acc7e40c3a (2026-08-17). Data as JSON: /api/errors/3da32cbd70b7711a. Report an issue: GitHub.

Appendix: source

Thrown at llmfit-python/hatch_build.py:158

    def _check_binary_version(bin_path: Path, expected_version: str) -> None:
        """Run the binary with ``--version`` and verify it matches the expected version.

        Raises ``RuntimeError`` on a mismatch — this indicates a stale build.
        """
        result = subprocess.run(
            [str(bin_path), "--version"],
            capture_output=True,
            check=True,
            text=True,
            timeout=5,
        )
        output = result.stdout.strip()  # e.g. "llmfit 0.9.8"
        match = re.match(r"^llmfit v?(\d+\.\d+\.\d+)$", output)
        if not match:
            raise RuntimeError(f"Unexpected output from '{bin_path} --version': {output!r}")
        binary_version = match.group(1)
        if binary_version != expected_version:
            raise RuntimeError(
                f"Binary version mismatch: binary at {bin_path} reports {binary_version!r} "
                f"but Cargo.toml (or LLMFIT_VERSION) says {expected_version!r}. "
                "Run 'make build' to recompile.",
            )
        print(f"  Binary version OK ({binary_version})")

    def initialize(self, version: str, build_data: dict) -> None:
        """Locate the platform binary and configure the wheel before it is built."""
        py_target_from_env = os.environ.get("LLMFIT_PYTHON_PLATFORM_TAG")
        if version == "editable" and py_target_from_env:
            raise ValueError(
                "LLMFIT_PYTHON_PLATFORM_TAG is not supported for editable installs. "
                "Let the build system detect the host platform instead.",
            )
        running_platform = self._detect_platform()
        py_target = py_target_from_env or running_platform
        if py_target not in TARGET_CONFIGS:
            raise ValueError(

View on GitHub (pinned to acc7e40c3a)