dotnet/efcore · error · ValueError

Unsupported compression format: {file_extension}

Error message

Unsupported compression format: {file_extension}

What it means

Raised as ValueError by extract_deb_file after picking the data.tar member: os.path.splitext gives an extension that is not .xz, .gz, or .zst - the only three the function knows how to decompress. Any other extension (e.g. .bz2, .lzma) or an empty extension falls through to the else branch.

Source

Thrown at eng/common/cross/install-debs.py:332

            subprocess.run([ar_tool, "p", os.path.abspath(deb_file), tar_filename], check=True, stdout=outfile, stderr=subprocess.PIPE)

        file_extension = os.path.splitext(tar_file_path)[1].lower()

        if file_extension == ".xz":
            mode = "r:xz"
        elif file_extension == ".gz":
            mode = "r:gz"
        elif file_extension == ".zst":
            # zstd is not supported by standard library yet
            decompressed_tar_path = tar_file_path.replace(".zst", "")
            with open(tar_file_path, "rb") as zst_file, open(decompressed_tar_path, "wb") as decompressed_file:
                dctx = zstandard.ZstdDecompressor()
                dctx.copy_stream(zst_file, decompressed_file)

            tar_file_path = decompressed_tar_path
            mode = "r"
        else:
            raise ValueError(f"Unsupported compression format: {file_extension}")

        with tarfile.open(tar_file_path, mode) as tar:
            tar.extractall(path=extract_dir, filter=_rootfs_extraction_filter)

def _rootfs_extraction_filter(member, dest_path):
    """Tarfile extraction filter based on the 'data' filter that additionally
    rewrites absolute-target symlinks/hardlinks into rootfs-relative paths.
    """
    if (member.issym() or member.islnk()) and os.path.isabs(member.linkname):
        link_dir = os.path.dirname(member.name)
        new_linkname = os.path.relpath(member.linkname.lstrip('/'),
                                       start=link_dir or '.')
        member = member.replace(linkname=new_linkname, deep=False)
    return tarfile.data_filter(member, dest_path)

def finalize_setup(rootfsdir):
    lib_dir = os.path.join(rootfsdir, 'lib')
    usr_lib_dir = os.path.join(rootfsdir, 'usr', 'lib')

View on GitHub (pinned to dbf9771522)

Solutions

  1. Identify the member name from `ar t <deb>` to see the exact compression (data.tar.bz2, data.tar.lzma, etc.).
  2. Extend the if/elif chain in extract_deb_file to handle the new extension (e.g. '.bz2' -> mode 'r:bz2', available via the stdlib tarfile).
  3. If you cannot edit the script, repackage the .deb so its data.tar uses .gz/.xz/.zst, or pick a --suite whose debs use a supported format.
  4. Report the format upstream if a stock distro suite is shipping it - the script likely needs a one-line addition.

Example fix

# before
        if file_extension == ".xz":
            mode = "r:xz"
        elif file_extension == ".gz":
            mode = "r:gz"
        elif file_extension == ".zst":
            ...
        else:
            raise ValueError(f"Unsupported compression format: {file_extension}")
# after (add bzip2 support)
        if file_extension == ".xz":
            mode = "r:xz"
        elif file_extension == ".gz":
            mode = "r:gz"
        elif file_extension == ".bz2":
            mode = "r:bz2"
        elif file_extension == ".zst":
            ...
Defensive patterns

Strategy: validation

Validate before calling

# Validate the data.tar compression is supported before extract_deb_file decompresses
import subprocess, os

SUPPORTED = {'.xz', '.gz', '.zst'}

def deb_uses_supported_compression(deb_file, ar_tool='ar'):
    res = subprocess.run([ar_tool, 't', deb_file], capture_output=True, text=True, check=True)
    member = next((l.strip() for l in res.stdout.splitlines() if l.startswith('data.tar')), None)
    if not member:
        raise RuntimeError(f"{deb_file} has no data.tar member")
    ext = os.path.splitext(member)[1].lower()
    if ext not in SUPPORTED:
        raise RuntimeError(f"{deb_file} uses {ext} for data.tar; supported: {sorted(SUPPORTED)}")
    return ext

Try / catch

try:
    extract_deb_file(deb_file, tmp_dir, extract_dir, ar_tool)
except ValueError as e:
    if "Unsupported compression format" in str(e):
        # either repackage the .deb to .gz/.xz or pick a suite that uses a supported format
        raise SystemExit(f"{e}. Add a branch in extract_deb_file or switch suite.")
    raise

Prevention

When it happens

Trigger: extract_deb_file on a .deb whose data.tar member uses a compression the code does not handle - .tar.bz2 / .tar.lzma / uncompressed .tar - so os.path.splitext(tar_file_path)[1].lower() returns '.bz2'/'.lzma'/'/'.

Common situations: An older or niche distro/suite shipping .deb with bzip2-compressed data.tar; a third-party package using a non-standard compressor; a suite change where the distro switched formats and this script has not been updated.

Related errors


AI-assisted analysis of dotnet/efcore@dbf9771522 (2026-08-06). Data as JSON: /api/errors/36e0532410810b69. Report an issue: GitHub.