{"record":{"id":"9775bf6455e85424","repo":"langchain-ai/deepagents","slug":"could-not-find-target-name-inside-archive-name","errorCode":null,"errorMessage":"Could not find {target_name} inside {archive.name}","messagePattern":"Could not find (.+?) inside (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/managed_tools.py","lineNumber":631,"sourceCode":"    Raises:\n        FileNotFoundError: When the archive does not contain an `rg` binary.\n    \"\"\"\n    import tarfile\n    import zipfile\n\n    if archive.suffix == \".zip\":\n        with zipfile.ZipFile(archive) as zf:\n            _extract_zip_validated(zf, extract_root)\n    else:\n        with tarfile.open(archive, mode=\"r:*\") as tf:\n            tf.extractall(extract_root, filter=\"data\")\n\n    target_name = \"rg.exe\" if sys.platform == \"win32\" else \"rg\"\n    for path in extract_root.rglob(target_name):\n        if path.is_file():\n            return path\n    msg = f\"Could not find {target_name} inside {archive.name}\"\n    raise FileNotFoundError(msg)\n\n\ndef _extract_zip_validated(zf: zipfile.ZipFile, extract_root: Path) -> None:\n    \"\"\"Extract a zip archive after validating each member's path.\n\n    `ZipFile.extractall` does sanitize absolute paths and parent-relative\n    components on modern Python, but defense-in-depth here keeps the\n    SHA-256-verified archive from being the only line of defense against\n    a zip-slip variant in a future upstream archive.\n\n    Raises:\n        zipfile.BadZipFile: If a member would extract outside `extract_root`.\n    \"\"\"\n    import zipfile\n\n    extract_root.mkdir(parents=True, exist_ok=True)\n    root = extract_root.resolve()\n    for member in zf.infolist():","sourceCodeStart":613,"sourceCodeEnd":649,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/managed_tools.py#L613-L649","documentation":"`_extract_rg` raises `FileNotFoundError` when, after extracting the archive, no file named `rg` (or `rg.exe` on Windows) is found anywhere under the extraction root. This catches archives that are not the expected ripgrep release layout.","triggerScenarios":"`_install_ripgrep_sync` (or the direct test path) given an archive whose contents lack the binary — a wrong-architecture or wrong-platform release tarball, an HTML error page saved as `.tar.gz`, or an archive whose nested layout changed between ripgrep versions.","commonSituations":"Downloading the musl vs gnu vs macOS wrong variant; a proxy serving an error page with a `.tar.gz` name; upstream restructuring the archive's inner directories; on Windows, downloading the non-`windows` asset so only `rg` (no `rg.exe`) is present.","solutions":["Confirm the downloaded archive matches the current platform/arch and re-download the correct release asset","Inspect the archive (`tar -tzf <archive>`) to verify `rg` exists inside; if the layout changed, update the extraction/lookup logic in `_extract_rg`","If the file is actually an HTML/error page, fix the download URL and proxy configuration"],"exampleFix":"// before\n$ tar -tzf rg.tar.gz | head\nmusl-tools/   # wrong asset: no rg binary\n// after\n$ tar -tzf rg-14.1.0-x86_64-unknown-linux-musl.tar.gz | grep /rg$\nrg-14.1.0-x86_64-unknown-linux-musl/rg\n$ dcode install-tools   # with correct asset URL","handlingStrategy":"validation","validationCode":"import tarfile\nfrom pathlib import Path\n\ndef archive_contains(archive: Path, member_suffix: str) -> bool:\n    with tarfile.open(archive) as tf:\n        return any(m.name.endswith(member_suffix) for m in tf.getmembers())\n\nif not archive_contains(Path(\"rg.tar.gz\"), \"/rg\"):\n    raise SystemExit(\"wrong release asset: no rg binary inside\")","typeGuard":null,"tryCatchPattern":"try:\n    rg = _extract_rg(archive, extract_root)\nexcept FileNotFoundError as exc:\n    raise SystemExit(f\"bad tool archive: {exc}; re-download correct platform asset\")","preventionTips":["Download the release asset matching your exact platform and architecture","Check the first bytes of the archive (`file rg.tar.gz`) to catch HTML error pages served as archives","After upstream version bumps, verify the archive layout before pinning"],"tags":["archive","install","filesystem"],"backgroundTag":"archive-extract-failed","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}