{"record":{"id":"07026dbd51922356","repo":"ungoogled-software/ungoogled-chromium","slug":"s-for-7-zip-is-only-available-on-windows","errorCode":null,"errorMessage":"\"%s\" for 7-zip is only available on Windows","messagePattern":"\"(.+?)\" for 7-zip is only available on Windows","errorType":"exception","errorClass":"EnvironmentError","httpStatus":null,"severity":"error","filePath":"utils/_extraction.py","lineNumber":262,"sourceCode":"    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 7-Zip.\n    \"\"\"\n    # TODO: It would be nice to extend this to support arbitrary standard IO chaining of 7z\n    # instances, so _extract_tar_with_7z and other future formats could use this.\n    if extractors is None:\n        extractors = DEFAULT_EXTRACTORS\n    sevenzip_cmd = extractors.get(ExtractorEnum.SEVENZIP)\n    if sevenzip_cmd == USE_REGISTRY:\n        if not get_running_platform() == PlatformEnum.WINDOWS:\n            get_logger().error('\"%s\" for 7-zip is only available on Windows', sevenzip_cmd)\n            raise EnvironmentError()\n        sevenzip_cmd = str(_find_7z_by_registry())\n    sevenzip_bin = _find_extractor_by_cmd(sevenzip_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 = (sevenzip_bin, 'x', str(archive_path), '-aoa', f'-o{str(output_dir)}')\n    get_logger().debug('7z command line: %s', ' '.join(cmd))\n\n    result = subprocess.run(cmd, check=False)\n    if result.returncode != 0:\n        get_logger().error('7z command returned %s', result.returncode)\n        raise ChildProcessError()\n\n    _process_relative_to(output_dir, relative_to)\n\n","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/ungoogled-software/ungoogled-chromium/blob/f85e84a480e2e17c103de7013de94320f9a2ba39/utils/_extraction.py#L244-L280","documentation":"extract_with_7z raises EnvironmentError when the configured 7-zip extractor command is USE_REGISTRY (auto-discover via Windows registry) but the running platform is not Windows, since registry lookup only exists there. The configuration is simply invalid for the current OS.","triggerScenarios":"Using the default DEFAULT_EXTRACTORS (which set 7-zip to registry discovery) on Linux/macOS, or explicitly passing extractors={ExtractorEnum.SEVENZIP: USE_REGISTRY} off Windows.","commonSituations":"Same config shared across Windows dev machines and Linux CI, or library defaults applied on non-Windows without overriding the 7-zip path.","solutions":["Override the extractor on non-Windows: extractors={ExtractorEnum.SEVENZIP: '/usr/bin/7z'}","Only use registry-based discovery on Windows; branch on get_running_platform()","Install 7-zip/7za and pass its command path explicitly","Use extract_tar_file with the tar extractor on Unix systems"],"exampleFix":"// before\nextract_with_7z(archive, out)  # DEFAULT_EXTRACTORS uses USE_REGISTRY -> fails on Linux\n// after\nextract_with_7z(archive, out, extractors={ExtractorEnum.SEVENZIP: '7z'})","handlingStrategy":"validation","validationCode":"from utils.platform import get_running_platform\nfrom utils.platform_enum import PlatformEnum\nfrom utils.enum import ExtractorEnum\nfrom utils.const import USE_REGISTRY\nextractors = {ExtractorEnum.SEVENZIP: '7z'}\nif get_running_platform() == PlatformEnum.WINDOWS:\n    extractors[ExtractorEnum.SEVENZIP] = USE_REGISTRY","typeGuard":"def registry_ok(extractors, platform):\n    return not any(v == USE_REGISTRY for v in extractors.values()) or platform == PlatformEnum.WINDOWS","tryCatchPattern":"try:\n    extract_with_7z(archive, out, relative_to=rel)\nexcept EnvironmentError:\n    extractors = {ExtractorEnum.SEVENZIP: shutil.which('7z') or '7z'}\n    extract_with_7z(archive, out, relative_to=rel, extractors=extractors)","preventionTips":["Never rely on USE_REGISTRY defaults on non-Windows","Provide explicit extractor paths in CI configs","Branch on get_running_platform() in shared setup code","Check that a 7z binary exists (shutil.which) before calling"],"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"}