{"record":{"id":"14f08ba554be0e8f","repo":"ungoogled-software/ungoogled-chromium","slug":"s-for-winrar-is-only-available-on-windows","errorCode":null,"errorMessage":"\"%s\" for WinRAR is only available on Windows","messagePattern":"\"(.+?)\" for WinRAR is only available on Windows","errorType":"exception","errorClass":"EnvironmentError","httpStatus":null,"severity":"error","filePath":"utils/_extraction.py","lineNumber":300,"sourceCode":"    \"\"\"\n    Extract archives with WinRAR into the output directory.\n    Only supports archives with one layer of unpacking, so compressed tar archives don't work.\n\n    archive_path is the pathlib.Path to the archive to unpack\n    output_dir is a pathlib.Path to the directory to unpack. It must already exist.\n\n    relative_to is a pathlib.Path for directories that should be stripped relative to the\n    root of the archive.\n    extractors is a dictionary of PlatformEnum to a command or path to the\n    extractor binary. Defaults to 'tar' for tar, and '_use_registry' for WinRAR.\n    \"\"\"\n    if extractors is None:\n        extractors = DEFAULT_EXTRACTORS\n    winrar_cmd = extractors.get(ExtractorEnum.WINRAR)\n    if winrar_cmd == USE_REGISTRY:\n        if not get_running_platform() == PlatformEnum.WINDOWS:\n            get_logger().error('\"%s\" for WinRAR is only available on Windows', winrar_cmd)\n            raise EnvironmentError()\n        winrar_cmd = str(_find_winrar_by_registry())\n    winrar_bin = _find_extractor_by_cmd(winrar_cmd)\n\n    if not relative_to is None and (output_dir / relative_to).exists():\n        get_logger().error('Temporary unpacking directory already exists: %s',\n                           output_dir / relative_to)\n        raise FileExistsError()\n    cmd = (winrar_bin, 'x', '-o+', str(archive_path), str(output_dir))\n    get_logger().debug('WinRAR command line: %s', ' '.join(cmd))\n\n    result = subprocess.run(cmd, check=False)\n    if result.returncode != 0:\n        get_logger().error('WinRAR command returned %s', result.returncode)\n        raise ChildProcessError()\n\n    _process_relative_to(output_dir, relative_to)\n","sourceCodeStart":282,"sourceCodeEnd":317,"githubUrl":"https://github.com/ungoogled-software/ungoogled-chromium/blob/f85e84a480e2e17c103de7013de94320f9a2ba39/utils/_extraction.py#L282-L317","documentation":"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.","triggerScenarios":"Calling extract_with_winrar with default extractors (registry-based) on Linux/macOS, or explicitly passing USE_REGISTRY on non-Windows.","commonSituations":"Shared configuration across OSes, CI runners without Windows, or assuming WinRAR handling works cross-platform.","solutions":["Do not use extract_with_winrar on non-Windows; use extract_tar_file or extract_with_7z instead","Pass an explicit winrar command path if the platform check is the issue (only valid on Windows anyway)","Branch configuration on get_running_platform() before calling","Install and configure an alternative extractor for Unix systems"],"exampleFix":"// before\nextract_with_winrar(archive, out)  # USE_REGISTRY default -> fails on Linux\n// after\nif get_running_platform() == PlatformEnum.WINDOWS:\n    extract_with_winrar(archive, out)\nelse:\n    extract_tar_file(archive, out)","handlingStrategy":"validation","validationCode":"from utils.platform import get_running_platform\nfrom utils.platform_enum import PlatformEnum\nif get_running_platform() != PlatformEnum.WINDOWS:\n    raise RuntimeError('WinRAR registry lookup requires Windows; use extract_tar_file')","typeGuard":"def winrar_usable(extractors, platform):\n    return platform == PlatformEnum.WINDOWS or extractors.get(ExtractorEnum.WINRAR) != USE_REGISTRY","tryCatchPattern":"try:\n    extract_with_winrar(archive, out, relative_to=rel)\nexcept EnvironmentError:\n    extract_tar_file(archive, out, relative_to=rel)","preventionTips":["Restrict extract_with_winrar calls to Windows code paths","Configure explicit extractor commands per OS","Use extract_tar_file as the cross-platform default","Test platform-branching logic in CI on each OS"],"tags":["platform","configuration","windows-only"],"backgroundTag":"windows-only-registry-lookup","analyzedSha":"f85e84a480e2e17c103de7013de94320f9a2ba39","analyzedAt":"2026-08-29T10:07:17.606Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}