{"record":{"id":"d867195fad9b9f63","repo":"AlexsJones/llmfit","slug":"unexpected-output-from-bin-path-version-ou","errorCode":null,"errorMessage":"Unexpected output from '{bin_path} --version': {output!r}","messagePattern":"Unexpected output from '(.+?) --version': (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"llmfit-python/hatch_build.py","lineNumber":155,"sourceCode":"        )\n\n    @staticmethod\n    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()","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/AlexsJones/llmfit/blob/a9ac7ed91c1729cd93944bc1338e8313daaba8fa/llmfit-python/hatch_build.py#L137-L173","documentation":"Before packaging a binary, _check_binary_version() executes `<binary> --version` and requires stdout to match ^llmfit v?(\\d+\\.\\d+\\.\\d+)$ exactly (one line, bare semver). This RuntimeError means the command succeeded but its output deviates from that contract, so the hook cannot extract a comparable version. It only runs when the wheel target equals the running platform (native builds and editable installs).","triggerScenarios":"A binary that prints a suffixed version like `llmfit 0.9.8-dev` or `llmfit 0.9.8+gabcdef`; extra lines around the version (banner, build info); a wrapper script or shim at target/debug/llmfit instead of the real cargo artifact; an older/newer binary whose --version format changed; an empty stdout because the flag was renamed.","commonSituations":"A fork or locally modified main.rs printing additional text on --version; CI caching a binary built from a different branch; someone putting a shell wrapper in target/debug/; cargo build interrupted leaving a partial/odd artifact.","solutions":["Run the exact command from the message (`<bin_path> --version`) and compare its stdout to the expected single-line `llmfit <X.Y.Z>` format.","Rebuild the binary from this checkout: `cargo build` / `cargo build --release --target <triple>` so the artifact matches the current CLI code.","Delete any hand-placed wrapper or stale artifact at the reported path and let cargo regenerate it.","If the --version output format legitimately changed in llmfit-tui, update the regex at hatch_build.py:153 to accept the new shape."],"exampleFix":"# before\n$ ./target/debug/llmfit --version\nllmfit 0.9.8-dev (HEAD)\n# -> RuntimeError: Unexpected output from './target/debug/llmfit --version'\n\n# after\ncargo build  # rebuild from current source\n$ ./target/debug/llmfit --version\nllmfit 0.9.8\n# hook proceeds: 'Binary version OK (0.9.8)'","handlingStrategy":"validation","validationCode":"import re, subprocess\n\nout = subprocess.run(['./target/debug/llmfit', '--version'], capture_output=True, text=True, timeout=5).stdout.strip()\nassert re.match(r'^llmfit v?\\d+\\.\\d+\\.\\d+$', out), f'unexpected --version output: {out!r}'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep `--version` output exactly `llmfit <X.Y.Z>` (single line, no suffixes) in llmfit-tui's main.rs.","Never substitute wrappers or shims at target/debug/llmfit; let cargo own that path.","Smoke-test `<binary> --version` in CI before the wheel-build step.","If the output format must change, update the regex in hatch_build.py:153 in the same commit."],"tags":["python","rust","version","build","packaging"],"backgroundTag":"version-parsing-failed","analyzedSha":"a9ac7ed91c1729cd93944bc1338e8313daaba8fa","analyzedAt":"2026-08-16T19:19:11.438Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}