AlexsJones/llmfit · error · RuntimeError
Unexpected output from '{bin_path} --version': {output!r}
Error message
Unexpected output from '{bin_path} --version': {output!r} What it means
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).
Source
Thrown at llmfit-python/hatch_build.py:155
)
@staticmethod
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()View on GitHub (pinned to a9ac7ed91c)
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.
Example fix
# before $ ./target/debug/llmfit --version llmfit 0.9.8-dev (HEAD) # -> RuntimeError: Unexpected output from './target/debug/llmfit --version' # after cargo build # rebuild from current source $ ./target/debug/llmfit --version llmfit 0.9.8 # hook proceeds: 'Binary version OK (0.9.8)'
Defensive patterns
Strategy: validation
Validate before calling
import re, subprocess
out = subprocess.run(['./target/debug/llmfit', '--version'], capture_output=True, text=True, timeout=5).stdout.strip()
assert re.match(r'^llmfit v?\d+\.\d+\.\d+$', out), f'unexpected --version output: {out!r}' Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Invalid version: {version!r}
- Binary not found at {bin_path}. Expected it to be built for
- Binary version mismatch: binary at {bin_path} reports {binar
- No suitable wheel platform found for runtime platform {first
- No compiled binary found. Checked: {candidates} Run 'make
AI-assisted analysis of AlexsJones/llmfit@a9ac7ed91c (2026-08-16).
Data as JSON: /api/errors/d867195fad9b9f63.
Report an issue: GitHub.