langchain-ai/deepagents · error · FileNotFoundError
Could not find {target_name} inside {archive.name}
Error message
Could not find {target_name} inside {archive.name} What it means
`_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.
Source
Thrown at libs/code/deepagents_code/managed_tools.py:631
Raises:
FileNotFoundError: When the archive does not contain an `rg` binary.
"""
import tarfile
import zipfile
if archive.suffix == ".zip":
with zipfile.ZipFile(archive) as zf:
_extract_zip_validated(zf, extract_root)
else:
with tarfile.open(archive, mode="r:*") as tf:
tf.extractall(extract_root, filter="data")
target_name = "rg.exe" if sys.platform == "win32" else "rg"
for path in extract_root.rglob(target_name):
if path.is_file():
return path
msg = f"Could not find {target_name} inside {archive.name}"
raise FileNotFoundError(msg)
def _extract_zip_validated(zf: zipfile.ZipFile, extract_root: Path) -> None:
"""Extract a zip archive after validating each member's path.
`ZipFile.extractall` does sanitize absolute paths and parent-relative
components on modern Python, but defense-in-depth here keeps the
SHA-256-verified archive from being the only line of defense against
a zip-slip variant in a future upstream archive.
Raises:
zipfile.BadZipFile: If a member would extract outside `extract_root`.
"""
import zipfile
extract_root.mkdir(parents=True, exist_ok=True)
root = extract_root.resolve()
for member in zf.infolist():View on GitHub (pinned to a1af029e6e)
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
Example fix
// before $ tar -tzf rg.tar.gz | head musl-tools/ # wrong asset: no rg binary // after $ tar -tzf rg-14.1.0-x86_64-unknown-linux-musl.tar.gz | grep /rg$ rg-14.1.0-x86_64-unknown-linux-musl/rg $ dcode install-tools # with correct asset URL
Defensive patterns
Strategy: validation
Validate before calling
import tarfile
from pathlib import Path
def archive_contains(archive: Path, member_suffix: str) -> bool:
with tarfile.open(archive) as tf:
return any(m.name.endswith(member_suffix) for m in tf.getmembers())
if not archive_contains(Path("rg.tar.gz"), "/rg"):
raise SystemExit("wrong release asset: no rg binary inside") Try / catch
try:
rg = _extract_rg(archive, extract_root)
except FileNotFoundError as exc:
raise SystemExit(f"bad tool archive: {exc}; re-download correct platform asset") Prevention
- 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
When it happens
Trigger: `_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.
Common situations: 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.
Related errors
- Plugin source directory not found: {source}
- debug log directory is not a real directory: {path}
- debug log directory is not owned by the current user: {path}
- Cannot determine whether {str(left)!r} is {str(right)!r}: {e
- Invalid DEEPAGENTS_HOME {str(root)!r}: exists but cannot be
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/9775bf6455e85424.
Report an issue: GitHub.