ungoogled-software/ungoogled-chromium · error · EnvironmentError

"%s" for WinRAR is only available on Windows

Error message

"%s" for WinRAR is only available on Windows

What it means

extract_with_winrar raises EnvironmentError when the WinRAR command is set to USE_REGISTRY but the platform is not Windows, because WinRAR registry auto-discovery is inherently Windows-only.

Source

Thrown at utils/_extraction.py:300

    """
    Extract archives with WinRAR into the output directory.
    Only supports archives with one layer of unpacking, so compressed tar archives don't work.

    archive_path is the pathlib.Path to the archive to unpack
    output_dir is a pathlib.Path to the directory to unpack. It must already exist.

    relative_to is a pathlib.Path for directories that should be stripped relative to the
    root of the archive.
    extractors is a dictionary of PlatformEnum to a command or path to the
    extractor binary. Defaults to 'tar' for tar, and '_use_registry' for WinRAR.
    """
    if extractors is None:
        extractors = DEFAULT_EXTRACTORS
    winrar_cmd = extractors.get(ExtractorEnum.WINRAR)
    if winrar_cmd == USE_REGISTRY:
        if not get_running_platform() == PlatformEnum.WINDOWS:
            get_logger().error('"%s" for WinRAR is only available on Windows', winrar_cmd)
            raise EnvironmentError()
        winrar_cmd = str(_find_winrar_by_registry())
    winrar_bin = _find_extractor_by_cmd(winrar_cmd)

    if not relative_to is None and (output_dir / relative_to).exists():
        get_logger().error('Temporary unpacking directory already exists: %s',
                           output_dir / relative_to)
        raise FileExistsError()
    cmd = (winrar_bin, 'x', '-o+', str(archive_path), str(output_dir))
    get_logger().debug('WinRAR command line: %s', ' '.join(cmd))

    result = subprocess.run(cmd, check=False)
    if result.returncode != 0:
        get_logger().error('WinRAR command returned %s', result.returncode)
        raise ChildProcessError()

    _process_relative_to(output_dir, relative_to)

View on GitHub (pinned to f85e84a480)

Solutions

  1. Do not use extract_with_winrar on non-Windows; use extract_tar_file or extract_with_7z instead
  2. Pass an explicit winrar command path if the platform check is the issue (only valid on Windows anyway)
  3. Branch configuration on get_running_platform() before calling
  4. Install and configure an alternative extractor for Unix systems

Example fix

// before
extract_with_winrar(archive, out)  # USE_REGISTRY default -> fails on Linux
// after
if get_running_platform() == PlatformEnum.WINDOWS:
    extract_with_winrar(archive, out)
else:
    extract_tar_file(archive, out)
Defensive patterns

Strategy: validation

Validate before calling

from utils.platform import get_running_platform
from utils.platform_enum import PlatformEnum
if get_running_platform() != PlatformEnum.WINDOWS:
    raise RuntimeError('WinRAR registry lookup requires Windows; use extract_tar_file')

Type guard

def winrar_usable(extractors, platform):
    return platform == PlatformEnum.WINDOWS or extractors.get(ExtractorEnum.WINRAR) != USE_REGISTRY

Try / catch

try:
    extract_with_winrar(archive, out, relative_to=rel)
except EnvironmentError:
    extract_tar_file(archive, out, relative_to=rel)

Prevention

When it happens

Trigger: Calling extract_with_winrar with default extractors (registry-based) on Linux/macOS, or explicitly passing USE_REGISTRY on non-Windows.

Common situations: Shared configuration across OSes, CI runners without Windows, or assuming WinRAR handling works cross-platform.

Related errors


AI-assisted analysis of ungoogled-software/ungoogled-chromium@f85e84a480 (2026-08-29). Data as JSON: /api/errors/14f08ba554be0e8f. Report an issue: GitHub.