{"record":{"id":"fb67956123cf30eb","repo":"dotnet/aspnetcore","slug":"could-not-find-data-tar-in-deb-file","errorCode":null,"errorMessage":"Could not find 'data.tar.*' in {deb_file}.","messagePattern":"Could not find 'data\\.tar\\.\\*' in (.+?)\\.","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"eng/common/cross/install-debs.py","lineNumber":308,"sourceCode":"\n    print(\"All done!\")\n\ndef extract_deb_file(deb_file, tmp_dir, extract_dir, ar_tool):\n    \"\"\"Extract .deb file contents\"\"\"\n\n    os.makedirs(extract_dir, exist_ok=True)\n\n    with tempfile.TemporaryDirectory(dir=tmp_dir) as tmp_subdir:\n        result = subprocess.run([ar_tool, \"t\", os.path.abspath(deb_file)], cwd=tmp_subdir, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n\n        tar_filename = None\n        for line in result.stdout.decode().splitlines():\n            if line.startswith(\"data.tar\"):\n                tar_filename = line.strip()\n                break\n\n        if not tar_filename:\n            raise FileNotFoundError(f\"Could not find 'data.tar.*' in {deb_file}.\")\n\n        tar_file_path = os.path.join(tmp_subdir, tar_filename)\n        print(f\"Extracting {tar_filename} from {deb_file}..\")\n\n        with open(tar_file_path, \"wb\") as outfile:\n            subprocess.run([ar_tool, \"p\", os.path.abspath(deb_file), tar_filename], check=True, stdout=outfile, stderr=subprocess.PIPE)\n\n        file_extension = os.path.splitext(tar_file_path)[1].lower()\n\n        if file_extension == \".xz\":\n            mode = \"r:xz\"\n        elif file_extension == \".gz\":\n            mode = \"r:gz\"\n        elif file_extension == \".zst\":\n            # zstd is not supported by standard library yet\n            decompressed_tar_path = tar_file_path.replace(\".zst\", \"\")\n            with open(tar_file_path, \"rb\") as zst_file, open(decompressed_tar_path, \"wb\") as decompressed_file:\n                dctx = zstandard.ZstdDecompressor()","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/eng/common/cross/install-debs.py#L290-L326","documentation":"Raised as FileNotFoundError by extract_deb_file when `ar t <deb>` lists no member whose name starts with 'data.tar'. Every conformant .deb archive contains data.tar.<comp>; the throw means the file is not a .deb, is corrupt, or is a different archive format.","triggerScenarios":"subprocess.run([ar_tool, 't', deb_file]) succeeds (check=True) but none of the stdout lines starts with 'data.tar', so tar_filename stays None and the raise fires.","commonSituations":"Downloaded file is actually an HTML error page saved with a .deb extension (mirror 404 page returned 200 with HTML); download was truncated so the ar archive is incomplete; wrong --artool (e.g. llvm-ar in a mode that lists differently); file is a .udeb or .ddeb with a different member layout; disk full mid-download so the file is partial.","solutions":["Inspect the file: `file path/to/foo.deb` and `ar t path/to/foo.deb` — if it is HTML or empty, the download itself was wrong (see errors 345/346/347).","Re-run with a different --mirror to rule out a mirror serving an error page with HTTP 200.","Confirm the --artool exists and is a real GNU/BSD ar (run `ar --version` or `llvm-ar --version`).","Verify disk space in the tmp_dir; a partial write leaves a truncated archive that lists no members."],"exampleFix":"# before\npython3 install-debs.py --artool llvm-ar --mirror http://bad-mirror ... \n# 'Could not find data.tar.* in rootfs/cache/libc6.deb' (mirror served HTML)\n\n# after\ncurl -I http://bad-mirror/.../libc6_1.0_amd64.deb   # discover it returns HTML\npython3 install-debs.py --artool ar --mirror http://deb.debian.org/debian ...","handlingStrategy":"validation","validationCode":"# After download, before extraction, assert each .deb is a real ar archive with data.tar:\nfor f in tmp/*.deb; do\n  ar t \"$f\" 2>/dev/null | grep -q '^data\\.tar' || { echo \"not a valid deb: $f\"; file \"$f\"; exit 1; }\ndone","typeGuard":"import os, subprocess\ndef deb_has_data_tar(path: str) -> bool:\n    if not os.path.isfile(path) or os.path.getsize(path) < 100: return False\n    r = subprocess.run(['ar', 't', path], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)\n    return any(line.startswith('data.tar') for line in r.stdout.decode().splitlines())","tryCatchPattern":null,"preventionTips":["Check `file foo.deb` after download to catch HTML error pages saved as .deb.","Ensure adequate disk space in tmp_dir to avoid truncated writes.","Validate the --artool (`ar --version`) before the run."],"tags":["python","debian","archive","ar","filenotfound","cross-build"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}