ungoogled-software/ungoogled-chromium · error · EnvironmentError
"%s" for 7-zip is only available on Windows
Error message
"%s" for 7-zip is only available on Windows
What it means
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.
Source
Thrown at utils/_extraction.py:262
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 7-Zip.
"""
# TODO: It would be nice to extend this to support arbitrary standard IO chaining of 7z
# instances, so _extract_tar_with_7z and other future formats could use this.
if extractors is None:
extractors = DEFAULT_EXTRACTORS
sevenzip_cmd = extractors.get(ExtractorEnum.SEVENZIP)
if sevenzip_cmd == USE_REGISTRY:
if not get_running_platform() == PlatformEnum.WINDOWS:
get_logger().error('"%s" for 7-zip is only available on Windows', sevenzip_cmd)
raise EnvironmentError()
sevenzip_cmd = str(_find_7z_by_registry())
sevenzip_bin = _find_extractor_by_cmd(sevenzip_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 = (sevenzip_bin, 'x', str(archive_path), '-aoa', f'-o{str(output_dir)}')
get_logger().debug('7z command line: %s', ' '.join(cmd))
result = subprocess.run(cmd, check=False)
if result.returncode != 0:
get_logger().error('7z command returned %s', result.returncode)
raise ChildProcessError()
_process_relative_to(output_dir, relative_to)
View on GitHub (pinned to f85e84a480)
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
Example fix
// before
extract_with_7z(archive, out) # DEFAULT_EXTRACTORS uses USE_REGISTRY -> fails on Linux
// after
extract_with_7z(archive, out, extractors={ExtractorEnum.SEVENZIP: '7z'}) Defensive patterns
Strategy: validation
Validate before calling
from utils.platform import get_running_platform
from utils.platform_enum import PlatformEnum
from utils.enum import ExtractorEnum
from utils.const import USE_REGISTRY
extractors = {ExtractorEnum.SEVENZIP: '7z'}
if get_running_platform() == PlatformEnum.WINDOWS:
extractors[ExtractorEnum.SEVENZIP] = USE_REGISTRY Type guard
def registry_ok(extractors, platform):
return not any(v == USE_REGISTRY for v in extractors.values()) or platform == PlatformEnum.WINDOWS Try / catch
try:
extract_with_7z(archive, out, relative_to=rel)
except EnvironmentError:
extractors = {ExtractorEnum.SEVENZIP: shutil.which('7z') or '7z'}
extract_with_7z(archive, out, relative_to=rel, extractors=extractors) Prevention
- 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
When it happens
Trigger: 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.
Common situations: Same config shared across Windows dev machines and Linux CI, or library defaults applied on non-Windows without overriding the 7-zip path.
Related errors
AI-assisted analysis of ungoogled-software/ungoogled-chromium@f85e84a480 (2026-08-29).
Data as JSON: /api/errors/07026dbd51922356.
Report an issue: GitHub.