{"record":{"id":"3da32cbd70b7711a","repo":"AlexsJones/llmfit","slug":"binary-version-mismatch-binary-at-bin-path-repo","errorCode":null,"errorMessage":"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.","messagePattern":"Binary version mismatch: binary at (.+?) reports (.+?) but Cargo\\.toml \\(or LLMFIT_VERSION\\) says (.+?)\\. Run 'make build' to recompile\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"llmfit-python/hatch_build.py","lineNumber":158,"sourceCode":"    def _check_binary_version(bin_path: Path, expected_version: str) -> None:\n        \"\"\"Run the binary with ``--version`` and verify it matches the expected version.\n\n        Raises ``RuntimeError`` on a mismatch — this indicates a stale build.\n        \"\"\"\n        result = subprocess.run(\n            [str(bin_path), \"--version\"],\n            capture_output=True,\n            check=True,\n            text=True,\n            timeout=5,\n        )\n        output = result.stdout.strip()  # e.g. \"llmfit 0.9.8\"\n        match = re.match(r\"^llmfit v?(\\d+\\.\\d+\\.\\d+)$\", output)\n        if not match:\n            raise RuntimeError(f\"Unexpected output from '{bin_path} --version': {output!r}\")\n        binary_version = match.group(1)\n        if binary_version != expected_version:\n            raise RuntimeError(\n                f\"Binary version mismatch: binary at {bin_path} reports {binary_version!r} \"\n                f\"but Cargo.toml (or LLMFIT_VERSION) says {expected_version!r}. \"\n                \"Run 'make build' to recompile.\",\n            )\n        print(f\"  Binary version OK ({binary_version})\")\n\n    def initialize(self, version: str, build_data: dict) -> None:\n        \"\"\"Locate the platform binary and configure the wheel before it is built.\"\"\"\n        py_target_from_env = os.environ.get(\"LLMFIT_PYTHON_PLATFORM_TAG\")\n        if version == \"editable\" and py_target_from_env:\n            raise ValueError(\n                \"LLMFIT_PYTHON_PLATFORM_TAG is not supported for editable installs. \"\n                \"Let the build system detect the host platform instead.\",\n            )\n        running_platform = self._detect_platform()\n        py_target = py_target_from_env or running_platform\n        if py_target not in TARGET_CONFIGS:\n            raise ValueError(","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/AlexsJones/llmfit/blob/a9ac7ed91c1729cd93944bc1338e8313daaba8fa/llmfit-python/hatch_build.py#L140-L176","documentation":"_check_binary_version() compares the binary's self-reported semver against the version the Python package is about to publish (metadata.version, sourced from LLMFIT_VERSION or Cargo.toml). This RuntimeError signals a stale artifact: the binary on disk was compiled before the version bump (or the override), so shipping it would put an old llmfit inside a newer-labelled wheel. It fires only when the wheel target equals the running platform, since a foreign-architecture binary cannot be executed to be checked.","triggerScenarios":"Cargo.toml workspace version bumped from 0.9.7 to 0.9.8 but `cargo build` not re-run before `uv build`; CI exporting LLMFIT_VERSION=0.9.9 for a release while target/release holds an 0.9.8 binary; checking out a newer tag without rebuilding; switching branches with different versions.","commonSituations":"Release automation that bumps versions in a separate step from compilation; developers reusing a long-lived target/ directory across version bumps; LLMFIT_VERSION left over in the environment from a previous release job.","solutions":["Recompile as the message says: `make build` (debug/editable) or `cargo build --release --target <triple>` (wheel builds), then retry.","If LLMFIT_VERSION is set, verify it matches what the binary reports: run `<bin_path> --version` and `echo $LLMFIT_VERSION`.","Unset a stale override when it is not intentional: `unset LLMFIT_VERSION` so Cargo.toml is the single source of truth.","In CI, always run the cargo build step after the version-bump step in the same job."],"exampleFix":"# before\n# Cargo.toml bumped to 0.9.8, target/release/llmfit still from 0.9.7\nuv build  # RuntimeError: Binary version mismatch: binary reports '0.9.7' ... says '0.9.8'\n\n# after\ncargo build --release --target x86_64-unknown-linux-gnu\nuv build  # prints 'Binary version OK (0.9.8)'","handlingStrategy":"validation","validationCode":"import os, re, subprocess, tomllib\n\nroot = Path.cwd()\nexpected = os.environ.get('LLMFIT_VERSION') or tomllib.loads((root / 'Cargo.toml').read_text())['workspace']['package']['version']\nreported = re.match(r'^llmfit v?(.+)$', subprocess.run([str(root / 'target/release/llmfit'), '--version'], capture_output=True, text=True).stdout.strip()).group(1)\nif reported != expected:\n    raise SystemExit(f'stale binary {reported} != {expected}; run cargo build --release first')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always rebuild (cargo build / make build) after bumping the workspace version.","Run the cargo build step in the same CI job and after any version-bump step.","Unset LLMFIT_VERSION when it is not intentionally overriding for this build.","Treat target/ as disposable: after branch/tag switches, rebuild before packaging."],"tags":["python","rust","version","stale-build","packaging"],"backgroundTag":"stale-build-artifact","analyzedSha":"a9ac7ed91c1729cd93944bc1338e8313daaba8fa","analyzedAt":"2026-08-16T19:19:11.438Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}