AlexsJones/llmfit · error · FileNotFoundError

Binary not found at . Expected it to be built for target .

Error message

Binary not found at {bin_path}. Expected it to be built for target {upstream_target!r}.

What it means

Raised by LlmfitBinaryBuildHook._find_binary_for_target() when building a standard (release) wheel. Hatchling expects the Rust binary to already exist at target/<upstream_target>/release/llmfit (or llmfit.exe), i.e. the location Cargo produces when built with an explicit --target. The hook never compiles Rust itself, so a missing cross-compiled artifact is a FileNotFoundError.

Solutions

  1. Build the binary for the exact upstream target: `cargo build --release --target x86_64-unknown-linux-gnu` (substitute the triple from the error message / TARGET_CONFIGS)
  2. Add the Rust target toolchain first if missing: `rustup target add aarch64-unknown-linux-gnu`
  3. For local builds where you just want a wheel of the host binary, build for the host and let platform detection pick it, or use an editable install which falls back to target/debug and target/release

Example fix

# before
uv build
# => FileNotFoundError: Binary not found at .../target/aarch64-unknown-linux-gnu/release/llmfit

# after
rustup target add aarch64-unknown-linux-gnu
cargo build --release --target aarch64-unknown-linux-gnu
uv build
Defensive patterns

Strategy: validation

Validate before calling

import os
from pathlib import Path
from hatch_build import TARGET_CONFIGS
py_target = os.environ.get("LLMFIT_PYTHON_PLATFORM_TAG", "manylinux_2_17_x86_64")
triple, name = TARGET_CONFIGS[py_target]
bin_path = Path("target") / triple / "release" / name
if not bin_path.is_file():
    raise SystemExit(f"missing {bin_path} — run `cargo build --release --target {triple}` first")

Try / catch

try:
    bin_path = hook._find_binary_for_target(root, py_target)
except FileNotFoundError as e:
    raise SystemExit(f"pre-build rust artifact missing: {e}")

Prevention

When it happens

Trigger: Running `uv build` / `hatch build` (standard version) without first running `cargo build --release --target <triple>` for the selected wheel platform — including when LLMFIT_PYTHON_PLATFORM_TAG selects a cross target whose artifact was never produced, or after `cargo clean` removed target/.

Common situations: CI release matrix that builds the wheel before the Rust cross-compile step; a developer copying the wheel-building step to a new machine without the cargo step; `cargo clean` between builds; running `rustup target add` but forgetting the actual build for that target.

Related errors


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

Appendix: source

Thrown at llmfit-python/hatch_build.py:113

    def _detect_platform() -> str:
        """Return the best platform tag for the current machine."""
        best = next((t.platform for t in sys_tags() if t.platform in TARGET_CONFIGS), None)
        if best is not None:
            return best
        first = next(t.platform for t in sys_tags())
        raise RuntimeError(f"No suitable wheel platform found for runtime platform {first!r}.")

    @staticmethod
    def _find_binary_for_target(llmfit_root: Path, py_target: str) -> Path:
        """Find the binary compiled for a specific Rust target.

        Looks in ``target/{upstream_target}/release/``, which is where Cargo
        places the binary when built with ``--target``.
        """
        upstream_target, binary_name = TARGET_CONFIGS[py_target]
        bin_path = llmfit_root / "target" / upstream_target / "release" / binary_name
        if not bin_path.is_file():
            raise FileNotFoundError(
                f"Binary not found at {bin_path}. Expected it to be built for target {upstream_target!r}.",
            )
        return bin_path

    @staticmethod
    def _find_local_binary(llmfit_root: Path) -> Path:
        """Find the locally compiled binary in default Cargo output locations.

        Checks ``target/debug/`` first (from ``make build``), then
        ``target/release/`` (from ``make release``).
        """
        binary_name = "llmfit.exe" if sys.platform == "win32" else "llmfit"
        candidates = [
            llmfit_root / "target" / "debug" / binary_name,
            llmfit_root / "target" / "release" / binary_name,
        ]
        for candidate in candidates:
            if candidate.is_file():

View on GitHub (pinned to acc7e40c3a)