{"record":{"id":"9fd0c6f5f71ce35f","repo":"AlexsJones/llmfit","slug":"binary-not-found-at-bin-path-the-binary-selecti","errorCode":null,"errorMessage":"Binary not found at {bin_path}. The binary selection logic selected a file that does not exist.","messagePattern":"Binary not found at (.+?)\\. The binary selection logic selected a file that does not exist\\.","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"llmfit-python/hatch_build.py","lineNumber":197,"sourceCode":"\n        upstream_target, binary_name = TARGET_CONFIGS[py_target]\n        pypi_version: str = self.metadata.version\n\n        print(f\"  target={upstream_target}  version={pypi_version}  wheel tag=py3-none-{py_target}\")\n\n        llmfit_root = Path(self.root).parent\n        if version == \"editable\":\n            # For editable installs, look for target/debug/llmfit or target/release/llmfit (or llmfit.exe on Windows).\n            bin_path = self._find_local_binary(llmfit_root)\n        elif version == \"standard\":\n            # For release installs, look for e.g. target/x86_64-unknown-linux-gnu/release/llmfit on Linux.\n            bin_path = self._find_binary_for_target(llmfit_root, py_target)\n        else:\n            raise ValueError(f\"Unknown version: {version!r}\")\n\n        # Always check that the binary exists.\n        if not bin_path.is_file():\n            raise FileNotFoundError(\n                f\"Binary not found at {bin_path}. The binary selection logic selected a file that does not exist.\",\n            )\n\n        # If possible, check the self-reported version of the binary.\n        # If the binary was built for a different platform then it's not possible.\n        if py_target == running_platform:\n            self._check_binary_version(bin_path, pypi_version)\n\n        # Place the binary in the wheel's scripts directory so that the\n        # installer puts it in .venv/bin/ (or Scripts/ on Windows).\n        build_data[\"shared_scripts\"][str(bin_path.absolute())] = binary_name\n\n        # Override the platform tag so the wheel gets the correct platform-specific name.\n        build_data[\"tag\"] = f\"py3-none-{py_target}\"\n        build_data[\"pure_python\"] = False\n","sourceCodeStart":179,"sourceCodeEnd":213,"githubUrl":"https://github.com/AlexsJones/llmfit/blob/acc7e40c3a0afbd36510a92f2f8f3d5177cfc0fe/llmfit-python/hatch_build.py#L179-L213","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-run the build after the concurrent cargo operation finishes; ensure only one job mutates target/ at a time","Rebuild the binary (`make build` or the appropriate `cargo build --release --target <triple>`) and retry","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"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"from pathlib import Path\n# after selection, before pip/hatch build:\nif not Path(bin_path).is_file():\n    raise SystemExit(f\"{bin_path} vanished — rerun `make build` / cargo build --release --target <triple>\")","typeGuard":null,"tryCatchPattern":"for attempt in range(2):\n    try:\n        subprocess.run([\"uv\", \"build\"], check=True)\n        break\n    except subprocess.CalledProcessError:\n        if attempt:\n            raise\n        subprocess.run([\"make\", \"build\"], check=True)  # rebuild artifact, then retry","preventionTips":["Serialize cargo and packaging jobs so nothing mutates target/ mid-build","Use a per-job CARGO_TARGET_DIR in parallel CI","Treat this message as a race/logic-bug signal — it should never fire in a quiet workspace"],"tags":["python","packaging","build-artifact","race-condition"],"backgroundTag":"missing-build-artifact","analyzedSha":"acc7e40c3a0afbd36510a92f2f8f3d5177cfc0fe","analyzedAt":"2026-08-17T10:35:29.658Z","contentChangedAt":"2026-08-17T10:35:29.658Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}