{"record":{"id":"9a478925a8320b77","repo":"AlexsJones/llmfit","slug":"binary-not-found-at-bin-path-expected-it-to-be","errorCode":null,"errorMessage":"Binary not found at {bin_path}. Expected it to be built for target {upstream_target!r}.","messagePattern":"Binary not found at (.+?)\\. Expected it to be built for target (.+?)\\.","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"llmfit-python/hatch_build.py","lineNumber":113,"sourceCode":"    def _detect_platform() -> str:\n        \"\"\"Return the best platform tag for the current machine.\"\"\"\n        best = next((t.platform for t in sys_tags() if t.platform in TARGET_CONFIGS), None)\n        if best is not None:\n            return best\n        first = next(t.platform for t in sys_tags())\n        raise RuntimeError(f\"No suitable wheel platform found for runtime platform {first!r}.\")\n\n    @staticmethod\n    def _find_binary_for_target(llmfit_root: Path, py_target: str) -> Path:\n        \"\"\"Find the binary compiled for a specific Rust target.\n\n        Looks in ``target/{upstream_target}/release/``, which is where Cargo\n        places the binary when built with ``--target``.\n        \"\"\"\n        upstream_target, binary_name = TARGET_CONFIGS[py_target]\n        bin_path = llmfit_root / \"target\" / upstream_target / \"release\" / binary_name\n        if not bin_path.is_file():\n            raise FileNotFoundError(\n                f\"Binary not found at {bin_path}. Expected it to be built for target {upstream_target!r}.\",\n            )\n        return bin_path\n\n    @staticmethod\n    def _find_local_binary(llmfit_root: Path) -> Path:\n        \"\"\"Find the locally compiled binary in default Cargo output locations.\n\n        Checks ``target/debug/`` first (from ``make build``), then\n        ``target/release/`` (from ``make release``).\n        \"\"\"\n        binary_name = \"llmfit.exe\" if sys.platform == \"win32\" else \"llmfit\"\n        candidates = [\n            llmfit_root / \"target\" / \"debug\" / binary_name,\n            llmfit_root / \"target\" / \"release\" / binary_name,\n        ]\n        for candidate in candidates:\n            if candidate.is_file():","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/AlexsJones/llmfit/blob/a9ac7ed91c1729cd93944bc1338e8313daaba8fa/llmfit-python/hatch_build.py#L95-L131","documentation":"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.","triggerScenarios":"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/.","commonSituations":"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.","solutions":["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).","Verify the file exists: `ls target/<upstream_target>/release/llmfit*` from the repository root, then re-run `uv build`.","When cross-building, make sure the target is installed (`rustup target add <triple>`) and the cross-linker is configured before the cargo step.","Check that LLMFIT_PYTHON_PLATFORM_TAG matches a target you actually built; unset it to fall back to the host platform."],"exampleFix":"# before\nuv build  # FileNotFoundError: Binary not found at .../target/aarch64-unknown-linux-gnu/release/llmfit\n\n# after\nrustup target add aarch64-unknown-linux-gnu\ncargo build --release --target aarch64-unknown-linux-gnu\nLLMFIT_PYTHON_PLATFORM_TAG=manylinux_2_17_aarch64 uv build","handlingStrategy":"validation","validationCode":"import os\nfrom pathlib import Path\n\nrepo = Path(__file__).resolve().parents[1]  # repository root\nTARGETS = {\n    'manylinux_2_17_x86_64': 'x86_64-unknown-linux-gnu',\n    'manylinux_2_17_aarch64': 'aarch64-unknown-linux-gnu',\n    # ... mirror hatch_build.py TARGET_CONFIGS\n}\ntag = os.environ.get('LLMFIT_PYTHON_PLATFORM_TAG') or 'manylinux_2_17_x86_64'\nbinary = repo / 'target' / TARGETS[tag] / 'release' / ('llmfit.exe' if os.name == 'nt' else 'llmfit')\nassert binary.is_file(), f'Missing {binary}; run: cargo build --release --target {TARGETS[tag]}'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make `cargo build --release --target <triple>` a prerequisite step of `uv build` in CI, keyed to the same platform matrix.","Verify target/<triple>/release/llmfit exists immediately before the wheel-build step.","Install rustup targets (`rustup target add ...`) as part of the cross-build job setup.","Never run cargo clean between the Rust and Python build stages."],"tags":["python","rust","packaging","build","cross-compilation"],"backgroundTag":"missing-build-artifact","analyzedSha":"a9ac7ed91c1729cd93944bc1338e8313daaba8fa","analyzedAt":"2026-08-16T19:19:11.438Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}