AlexsJones/llmfit · error · RuntimeError
Unexpected output from
Error message
Unexpected output from '{bin_path} --version': {output!r} What it means
Raised by LlmfitBinaryBuildHook._check_binary_version(), which executes the packaged binary with `--version` and requires the stripped stdout to match exactly `llmfit X.Y.Z` or `llmfit vX.Y.Z` (regex ^llmfit v?(\d+\.\d+\.\d+)$). Any additional output on stdout — a commit hash, feature list, log line, or debug print — makes the match fail and raises this RuntimeError. Note the check only runs when the binary's platform matches the build host, and check=True would raise CalledProcessError instead for a nonzero exit.
Solutions
- Run `./target/release/llmfit --version` yourself and compare against the expected 'llmfit X.Y.Z' shape; remove any extra stdout output from the version path
- Rebuild the binary from a clean checkout (`make build`) in case a locally instrumented binary is being picked up
- If the richer version string is intentional, relax the regex in hatch_build.py to tolerate trailing text: r"^llmfit v?(\d+\.\d+\.\d+)(?:\s.*)?$"
Example fix
# before (hatch_build.py) match = re.match(r"^llmfit v?(\d+\.\d+\.\d+)$", output) # after — tolerate trailing build metadata match = re.match(r"^llmfit v?(\d+\.\d+\.\d+)(?:\s.*)?$", output)
Defensive patterns
Strategy: validation
Validate before calling
import re, subprocess, sys
out = subprocess.run(["./target/release/llmfit", "--version"], capture_output=True, text=True, timeout=5).stdout.strip()
if not re.fullmatch(r"llmfit v?\d+\.\d+\.\d+", out):
raise SystemExit(f"unexpected --version output {out!r} — fix binary output before packaging") Try / catch
try:
hook._check_binary_version(bin_path, expected)
except RuntimeError as e:
raise SystemExit(f"version probe failed: {e}") Prevention
- Keep the --version output exactly 'llmfit X.Y.Z'; put any extra banner on stderr or behind a flag
- Add a CLI integration test asserting the --version format so drift is caught in CI
- Never println! diagnostics in the binary before clap parses --version
When it happens
Trigger: The binary's `--version` output format drifts: someone adds build metadata (e.g. 'llmfit 0.9.8+abc1234' or 'llmfit 0.9.8 (debug)'), a library starts printing logs to stdout before clap formats the version, or a locally modified binary prints extra lines. Then any wheel build on that host fails.
Common situations: Changing the clap version string or adding startup banner output in llmfit-tui; building a wheel against a development binary with eprintln/println instrumentation; a distro-patched binary with branded version output.
Related errors
- Binary version mismatch: binary at
- Binary not found at . Expected it to be built for target .
- Binary not found at . The binary selection logic selected a…
- Invalid version
- llmfit binary not found at
AI-assisted analysis of AlexsJones/llmfit@acc7e40c3a (2026-08-17).
Data as JSON: /api/errors/d867195fad9b9f63.
Report an issue: GitHub.
Appendix: 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 acc7e40c3a)