AlexsJones/llmfit · error · FileNotFoundError

Binary not found at {bin_path}. Expected it to be built for

Error message

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

What it means

During a standard (wheel) build, _find_binary_for_target() expects the pre-built Rust binary at <repo>/target/<upstream_target>/release/llmfit(.exe) - exactly where `cargo build --release --target <triple>` puts it. This FileNotFoundError means that artifact was never produced (or was cleaned) for the selected wheel platform, so the wheel has nothing to package.

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 a9ac7ed91c)

Solutions

  1. Build the release binary for the exact Rust triple named in the message: `cargo build --release --target <upstream_target>` (or `make release` for the native target).
  2. Verify the file exists: `ls target/<upstream_target>/release/llmfit*` from the repository root, then re-run `uv build`.
  3. When cross-building, make sure the target is installed (`rustup target add <triple>`) and the cross-linker is configured before the cargo step.
  4. Check that LLMFIT_PYTHON_PLATFORM_TAG matches a target you actually built; unset it to fall back to the host platform.

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
LLMFIT_PYTHON_PLATFORM_TAG=manylinux_2_17_aarch64 uv build
Defensive patterns

Strategy: validation

Validate before calling

import os
from pathlib import Path

repo = Path(__file__).resolve().parents[1]  # repository root
TARGETS = {
    'manylinux_2_17_x86_64': 'x86_64-unknown-linux-gnu',
    'manylinux_2_17_aarch64': 'aarch64-unknown-linux-gnu',
    # ... mirror hatch_build.py TARGET_CONFIGS
}
tag = os.environ.get('LLMFIT_PYTHON_PLATFORM_TAG') or 'manylinux_2_17_x86_64'
binary = repo / 'target' / TARGETS[tag] / 'release' / ('llmfit.exe' if os.name == 'nt' else 'llmfit')
assert binary.is_file(), f'Missing {binary}; run: cargo build --release --target {TARGETS[tag]}'

Prevention

When it happens

Trigger: Running `uv build` without first running `cargo build --release --target x86_64-unknown-linux-gnu`; setting LLMFIT_PYTHON_PLATFORM_TAG=manylinux_2_17_aarch64 without ever cross-compiling `cargo build --release --target aarch64-unknown-linux-gnu`; after `cargo clean`; building from a copied tree that lacks target/.

Common situations: New contributor runs only the Python-side build steps; CI matrix builds aarch64 wheels on an x86_64 runner but skips the cross-compile job; make clean/make clean-all run between the Rust and Python build stages.

Related errors


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