AlexsJones/llmfit · error · FileNotFoundError

Binary not found at . The binary selection logic selected a…

Error message

Binary not found at {bin_path}. The binary selection logic selected a file that does not exist.

What it means

A second, defensive existence check in initialize(): after the selection logic picks bin_path (editable: target/debug|release; standard: target/<triple>/release), the path is re-verified before being registered in build_data['shared_scripts']. The selector helpers already raise their own FileNotFoundError with actionable messages, so this variant indicates the file disappeared between selection and check (TOCTOU) or a regression in the selection logic itself.

Solutions

  1. Re-run the build after the concurrent cargo operation finishes; ensure only one job mutates target/ at a time
  2. Rebuild the binary (`make build` or the appropriate `cargo build --release --target <triple>`) and retry
  3. If it reproduces deterministically, inspect the selection code path — the message explicitly says the selected file does not exist, which points at a logic regression rather than a race
Defensive patterns

Strategy: retry

Validate before calling

from pathlib import Path
# after selection, before pip/hatch build:
if not Path(bin_path).is_file():
    raise SystemExit(f"{bin_path} vanished — rerun `make build` / cargo build --release --target <triple>")

Try / catch

for attempt in range(2):
    try:
        subprocess.run(["uv", "build"], check=True)
        break
    except subprocess.CalledProcessError:
        if attempt:
            raise
        subprocess.run(["make", "build"], check=True)  # rebuild artifact, then retry

Prevention

When it happens

Trigger: A concurrent `cargo clean` or `cargo build` replacing the target/ tree while `uv build` runs; antivirus/backup tooling quarantining the binary mid-build; a bug introduced by editing _find_local_binary/_find_binary_for_target so they return a path they never verified.

Common situations: Parallel CI steps sharing one workspace (one cleans target/ while another builds the wheel); developers running `cargo clean` in a second terminal during a wheel build.

Related errors


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

Appendix: source

Thrown at llmfit-python/hatch_build.py:197

        upstream_target, binary_name = TARGET_CONFIGS[py_target]
        pypi_version: str = self.metadata.version

        print(f"  target={upstream_target}  version={pypi_version}  wheel tag=py3-none-{py_target}")

        llmfit_root = Path(self.root).parent
        if version == "editable":
            # For editable installs, look for target/debug/llmfit or target/release/llmfit (or llmfit.exe on Windows).
            bin_path = self._find_local_binary(llmfit_root)
        elif version == "standard":
            # For release installs, look for e.g. target/x86_64-unknown-linux-gnu/release/llmfit on Linux.
            bin_path = self._find_binary_for_target(llmfit_root, py_target)
        else:
            raise ValueError(f"Unknown version: {version!r}")

        # Always check that the binary exists.
        if not bin_path.is_file():
            raise FileNotFoundError(
                f"Binary not found at {bin_path}. The binary selection logic selected a file that does not exist.",
            )

        # If possible, check the self-reported version of the binary.
        # If the binary was built for a different platform then it's not possible.
        if py_target == running_platform:
            self._check_binary_version(bin_path, pypi_version)

        # Place the binary in the wheel's scripts directory so that the
        # installer puts it in .venv/bin/ (or Scripts/ on Windows).
        build_data["shared_scripts"][str(bin_path.absolute())] = binary_name

        # Override the platform tag so the wheel gets the correct platform-specific name.
        build_data["tag"] = f"py3-none-{py_target}"
        build_data["pure_python"] = False

View on GitHub (pinned to acc7e40c3a)