{"record":{"id":"ef2fcfa3a32d5c06","repo":"headroomlabs-ai/headroom","slug":"codebase-memory-mcp-binary-not-found-in-archive","errorCode":null,"errorMessage":"codebase-memory-mcp binary not found in archive","messagePattern":"codebase-memory-mcp binary not found in archive","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"headroom/graph/installer.py","lineNumber":89,"sourceCode":"    try:\n        if not url.startswith((\"http://\", \"https://\")):\n            raise ValueError(f\"Invalid URL: {url}\")\n\n        with urlopen(url, timeout=60) as response:  # noqa: S310\n            data = response.read()\n    except Exception as e:\n        raise RuntimeError(f\"Failed to download codebase-memory-mcp from {url}: {e}\") from e\n\n    # Extract binary from tar.gz\n    try:\n        with tarfile.open(fileobj=io.BytesIO(data), mode=\"r:gz\") as tar:\n            for member in tar.getmembers():\n                if member.name.endswith(CBM_BIN_NAME) or member.name == CBM_BIN_NAME:\n                    member.name = target_path.name\n                    tar.extract(member, CBM_BIN_DIR)\n                    break\n            else:\n                raise RuntimeError(\"codebase-memory-mcp binary not found in archive\")\n    except tarfile.TarError as e:\n        raise RuntimeError(f\"Failed to extract archive: {e}\") from e\n\n    # Make executable\n    target_path.chmod(target_path.stat().st_mode | stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH)\n\n    # Verify\n    try:\n        from headroom._subprocess import run\n\n        result = run(\n            [str(target_path), \"--version\"],\n            capture_output=True,\n            text=True,\n        )\n        if result.returncode == 0:\n            ver = result.stdout.strip()\n            logger.info(\"Installed: %s\", ver)","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/headroomlabs-ai/headroom/blob/322425c43bffde1ed0b64fecf3cf5951565dd82b/headroom/graph/installer.py#L71-L107","documentation":"Raised when the downloaded codebase-memory-mcp tar.gz opened successfully but no archive member matches the binary name (checked via member.name.endswith(CBM_BIN_NAME) or exact equality). It means the download itself succeeded but the archive layout is not what the installer expects — e.g. a wrong asset for the platform, an HTML error page saved as .tar.gz by a redirecting proxy, or an upstream packaging change that renamed the inner binary.","triggerScenarios":"A platform asset whose top-level binary is named differently (e.g. 'cbm' vs 'codebase-memory-mcp'); a captive portal / misbehaving mirror returning non-tar content that tarfile still opens; a release packaging regression upstream.","commonSituations":"Pinned versions whose asset layout changed mid-project; running in a container with a transparent HTTP proxy that mangles responses; unusual platform assets (windows zip repackaged as tar.gz).","solutions":["Download the URL manually and inspect: tar -tzf codebase-memory-mcp-<plat>.tar.gz — see what the inner binary is actually named.","If the name changed upstream, update CBM_BIN_NAME or upgrade headroom to a release matching the new layout.","If the 'archive' is HTML, fix the proxy/egress path — the URL is probably being redirected.","As a workaround, extract the correct binary manually and place it on PATH so the installer is bypassed."],"exampleFix":"# before\n# RuntimeError: codebase-memory-mcp binary not found in archive\n\n# after: inspect then work around\n$ tar -tzf codebase-memory-mcp-linux-amd64.tar.gz   # confirm inner name\n$ tar -xzf codebase-memory-mcp-linux-amd64.tar.gz -C ~/.local/bin/\n$ chmod +x ~/.local/bin/codebase-memory-mcp   # PATH lookup then short-circuits install","handlingStrategy":"fallback","validationCode":"import io, tarfile\n\ndef archive_has_binary(data: bytes, bin_name: str) -> bool:\n    try:\n        with tarfile.open(fileobj=io.BytesIO(data), mode=\"r:gz\") as tar:\n            return any(m.name.endswith(bin_name) or m.name == bin_name for m in tar.getmembers())\n    except tarfile.TarError:\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    install_cbm()\nexcept RuntimeError as e:\n    if \"binary not found in archive\" in str(e):\n        logger.warning(\"asset layout unexpected — installing manual binary\")\n        manual_install_cbm_from_path(\"./vendor/codebase-memory-mcp\")\n    else:\n        raise","preventionTips":["Pin CBM versions whose asset layout you have verified (tar -tzf).","If a proxy intercepts downloads, whitelist the GitHub release domain so you get real tarballs.","Vendor the extracted binary in your image on PATH to make installs hermetic."],"tags":["installer","archive","packaging","download","mismatch"],"backgroundTag":null,"analyzedSha":"322425c43bffde1ed0b64fecf3cf5951565dd82b","analyzedAt":"2026-08-15T01:03:05.481Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}