{"record":{"id":"1f79e63a9c2e5cdb","repo":"dotnet/maui","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":245,"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(f\"{ar_tool} t {os.path.abspath(deb_file)}\", cwd=tmp_subdir, check=True, shell=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        subprocess.run(f\"{ar_tool} p {os.path.abspath(deb_file)} {tar_filename} > {tar_file_path}\", check=True, shell=True)\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()\n                dctx.copy_stream(zst_file, decompressed_file)","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/eng/common/cross/install-debs.py#L227-L263","documentation":"extract_debs raises FileNotFoundError when `ar t` lists the archive contents and no entry starts with 'data.tar'. Every well-formed .deb must contain a data.tar.* member; its absence means the file is corrupt, truncated, or not actually a .deb (e.g. an HTML error page saved with a .deb extension).","triggerScenarios":"Pointing install-debs.py at a file that is not a valid .deb, a partially downloaded .deb, or one whose data member is named differently than the data.tar prefix the script expects.","commonSituations":"A broken mirror/proxy returning an HTML 404 saved as the .deb, a download interrupted leaving a truncated file, or an ar tool mismatch producing unexpected output.","solutions":["Verify the file with `ar t file.deb` and confirm a data.tar.* entry exists; re-download if missing.","Check the mirror URL and --suite; a wrong suite often yields a 404 body saved as the deb.","Ensure --artool points to a real BSD/GNU ar (default 'ar'); llvm-ar output format can differ.","Validate HTTP status of the deb download before extraction."],"exampleFix":"# before\n# silently corrupted file at debs/foo.deb\nextract_debs([\"debs/foo.deb\"], ...)\n\n# after\nimport subprocess\nout = subprocess.run([\"ar\", \"t\", \"debs/foo.deb\"], capture_output=True, text=True).stdout\nif not any(l.startswith(\"data.tar\") for l in out.splitlines()):\n    raise SystemExit(\"foo.deb is not a valid deb; re-download\")\nextract_debs([\"debs/foo.deb\"], ...)","handlingStrategy":"validation","validationCode":"import subprocess\nout = subprocess.run([ar_tool, 't', deb_file], capture_output=True, text=True).stdout\nif not any(l.startswith('data.tar') for l in out.splitlines()):\n    raise FileNotFoundError(f\"Not a valid deb: {deb_file}\")","typeGuard":"def is_valid_deb(deb_file, ar_tool='ar'):\n    import subprocess\n    out = subprocess.run([ar_tool,'t',deb_file],capture_output=True,text=True).stdout\n    return any(l.startswith('data.tar') for l in out.splitlines())","tryCatchPattern":"try:\n    extract_debs([deb], ...)\nexcept FileNotFoundError:\n    re_download(deb)","preventionTips":["Verify HTTP status codes when downloading debs.","Run `ar t` to sanity-check a deb before extraction.","Ensure --artool resolves to a real ar binary."],"tags":["python","cross-build","rootfs","packaging"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}