dotnet/runtime · error · ValueError

Unsupported compression format: {file_extension}

Error message

Unsupported compression format: {file_extension}

What it means

Raised by extract_deb_file() in install-debs.py when the data.tar archive member inside a .deb has a file extension that is not .xz, .gz, or .zst. These are the only three compression formats the extraction logic handles. The .zst path decompresses using the zstandard library, .xz and .gz use Python's tarfile module with built-in decompression.

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 60108ba66e)

Solutions

  1. Check the tar filename from 'ar t' output to see what extension the data.tar member actually has.
  2. Add a branch for the missing compression format (e.g., add '.bz2' with mode 'r:bz2' for tarfile, or handle '.lzma').
  3. Use a different suite/mirror whose packages use a supported compression format.
  4. Pre-decompress the data.tar externally and point the script at the uncompressed tar.

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 bz2 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":
    ...
else:
    raise ValueError(f"Unsupported compression format: {file_extension}")
Defensive patterns

Strategy: validation

Validate before calling

import os

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

def get_supported_compression(tar_filename: str) -> str:
    """Check if the data.tar compression format is supported."""
    ext = os.path.splitext(tar_filename)[1].lower()
    if ext not in SUPPORTED_EXTENSIONS:
        raise ValueError(
            f"Unsupported compression '{ext}'. Supported: {SUPPORTED_EXTENSIONS}. "
            f"You may need to pre-decompress the archive manually.")
    return ext

Type guard

null

Try / catch

try:
    extract_deb_file(deb_file, tmp_dir, extract_dir, ar_tool)
except ValueError as e:
    if "Unsupported compression" in str(e):
        # Attempt manual decompression as fallback
        logging.warning(f"{e}. Attempting manual extraction.")
        manual_extract_deb(deb_file, extract_dir)
    else:
        raise

Prevention

When it happens

Trigger: Triggered when os.path.splitext(tar_file_path)[1] returns an extension other than '.xz', '.gz', or '.zst'. The tar filename comes from the 'ar t' listing of the .deb. Modern Debian uses .xz or .zst; older releases may use .gz. A new compression format or a non-standard member name would trigger this.

Common situations: A distribution adopts a new compression format not yet handled by the script (historically, .bz2 was used by older Debian releases). A .deb built with non-standard tooling produces a data.tar with an unexpected extension. The .deb uses .lzma or .bz2 which were once common.

Related errors


AI-assisted analysis of dotnet/runtime@60108ba66e (2026-08-10). Data as JSON: /api/errors/054441fb94ab4689. Report an issue: GitHub.