jdx/mise · error · RuntimeError
failed to decompress #{archive}
Error message
failed to decompress #{archive} What it means
In the brew shim's unpack, single-file compressed archives (.gz/.xz/.bz2) are decompressed by piping through gzip/xz/bzip2 in a shell backtick. The failure check `$?.success?` failing raises this error, meaning the decompressor exited non-zero (corrupt archive, missing tool, or shell interpolation issue).
Source
Thrown at src/system/packages/brew/shim.rb:105
raise "#{context}: sha256 mismatch (expected #{sha256}, got #{actual})"
end
tmp.rename(dest)
end
dest
end
# unpack an archive the way brew stages sources: if the archive contains a
# single top-level directory, its contents become the stage root
def unpack(archive, dest)
dest.mkpath
case archive.basename.to_s
when /\.(tar\.(gz|xz|bz2|zst)|tgz|txz|tbz2?|tar|crate)\z/i
system_or_die "tar", "xf", archive.to_s, "-C", dest.to_s
when /\.zip\z/i
system_or_die "unzip", "-qo", archive.to_s, "-d", dest.to_s
when /\.(gz|xz|bz2)\z/i
data = `#{archive.to_s =~ /xz\z/ ? "xz -dc" : archive.to_s =~ /bz2\z/ ? "bzip2 -dc" : "gzip -dc"} #{Shellwords.escape(archive.to_s)}`
raise "failed to decompress #{archive}" unless $?.success?
(dest + archive.basename.to_s.sub(/\.(gz|xz|bz2)\z/i, "")).binwrite(data)
else
FileUtils.cp archive, dest
end
entries = dest.children
return entries.first if entries.size == 1 && entries.first.directory?
dest
end
def system_or_die(*args)
raise "command failed: #{args.join(" ")}" unless system(*args)
end
end
module OS
def self.mac? = RbConfig::CONFIG["host_os"].include?("darwin")
def self.linux? = RbConfig::CONFIG["host_os"].include?("linux")
View on GitHub (pinned to afd2eddd3a)
Solutions
- Ensure the required decompressor is installed (apt-get install xz-utils / bzip2) and on PATH.
- Verify the archive is valid: gzip -t / xz -t <archive>; re-download if corrupt.
- Confirm the file is actually a single-file compressed stream, not a tarball (use `file archive`); the extension must match the content.
- If the archive is fine but still failing, check disk space in the destination.
Example fix
// before (minimal image without xz) # no xz installed // after RUN apt-get update && apt-get install -y xz-utils
Defensive patterns
Strategy: validation
Validate before calling
# ensure decompressors exist before unpack
%w[gzip xz bzip2 tar].each do |t|
raise "missing tool: #{t}" unless system("command -v #{t}", out: File::NULL)
end Try / catch
begin
MiseDownload.unpack(archive, dest)
rescue RuntimeError => e
raise unless e.message.start_with?("failed to decompress")
# install xz/bzip2 or re-fetch a valid archive
end Prevention
- Install gzip, xz-utils, and bzip2 in base images used for mise package installs.
- Validate archives with gzip -t / xz -t after download.
- Match archive extensions to actual content types.
When it happens
Trigger: unpack called on a .gz/.xz/.bz2 file whose stream is corrupt or truncated, or on a system where xz/bzip2/gzip is not installed, or when the archive filename contains characters the shell interpolation mishandles.
Common situations: Partially downloaded .tar.gz misclassified as .gz; minimal container images lacking xz; checksum-verified but corrupt-at-source archives.
Related errors
- command failed: #{args.join(" ")}
- brew-cask:{}: unsupported archive type for {}
- brew-cask: nested archive depth exceeds {MAX_NESTED_CASK_ARC
- #{context}: missing sha256
- no precompiled ruby is available for this platform To compil
AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09).
Data as JSON: /api/errors/075d8b95c83f5ee8.
Report an issue: GitHub.