{"record":{"id":"075d8b95c83f5ee8","repo":"jdx/mise","slug":"failed-to-decompress-archive","errorCode":null,"errorMessage":"failed to decompress #{archive}","messagePattern":"failed to decompress #(.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/shim.rb","lineNumber":105,"sourceCode":"        raise \"#{context}: sha256 mismatch (expected #{sha256}, got #{actual})\"\n      end\n      tmp.rename(dest)\n    end\n    dest\n  end\n\n  # unpack an archive the way brew stages sources: if the archive contains a\n  # single top-level directory, its contents become the stage root\n  def unpack(archive, dest)\n    dest.mkpath\n    case archive.basename.to_s\n    when /\\.(tar\\.(gz|xz|bz2|zst)|tgz|txz|tbz2?|tar|crate)\\z/i\n      system_or_die \"tar\", \"xf\", archive.to_s, \"-C\", dest.to_s\n    when /\\.zip\\z/i\n      system_or_die \"unzip\", \"-qo\", archive.to_s, \"-d\", dest.to_s\n    when /\\.(gz|xz|bz2)\\z/i\n      data = `#{archive.to_s =~ /xz\\z/ ? \"xz -dc\" : archive.to_s =~ /bz2\\z/ ? \"bzip2 -dc\" : \"gzip -dc\"} #{Shellwords.escape(archive.to_s)}`\n      raise \"failed to decompress #{archive}\" unless $?.success?\n      (dest + archive.basename.to_s.sub(/\\.(gz|xz|bz2)\\z/i, \"\")).binwrite(data)\n    else\n      FileUtils.cp archive, dest\n    end\n    entries = dest.children\n    return entries.first if entries.size == 1 && entries.first.directory?\n    dest\n  end\n\n  def system_or_die(*args)\n    raise \"command failed: #{args.join(\" \")}\" unless system(*args)\n  end\nend\n\nmodule OS\n  def self.mac? = RbConfig::CONFIG[\"host_os\"].include?(\"darwin\")\n  def self.linux? = RbConfig::CONFIG[\"host_os\"].include?(\"linux\")\n","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/packages/brew/shim.rb#L87-L123","documentation":"A Ruby raise in the brew shim's unpack: one of the gzip/xz/bzip2 decompressor commands exited non-zero while expanding a single-file compressed archive. tar/zip failures go through system_or_die instead; this branch captures output via backticks and checks $?.success?.","triggerScenarios":"The archive file is truncated or corrupt, `xz`/`bzip2`/`gzip` is missing from PATH, or the cached file at that path isn't actually a compressed stream of the claimed format.","commonSituations":"Interrupted downloads leaving partial caches, tools like xz not installed in minimal container images, downloading an HTML error page saved with a .gz name.","solutions":["Delete the corrupt cached file under MISE_BREW_CACHE and re-run so it re-downloads","Install the missing decompressor (e.g. `apt-get install xz-utils` or `brew install xz`)","Confirm the URL actually serves the compressed file (curl -sI the URL, check content-type)","Verify the archive manually: `gzip -t <file>` / `xz -t <file>`"],"exampleFix":"// environment before\n$ which xz  # not found\n// after\n$ apt-get install -y xz-utils  # or brew install xz","handlingStrategy":"validation","validationCode":"raise \"missing xz\" unless system(\"which\", \"xz\")\nsystem(\"xz\", \"-t\", archive.to_s) or raise \"corrupt archive #{archive}\"","typeGuard":null,"tryCatchPattern":"begin\n  MiseDownload.unpack(archive, dest)\nrescue RuntimeError => e\n  warn \"unpack failed: #{e.message}; clearing cache\"\n  FileUtils.rm_f(archive)\nend","preventionTips":["Install xz-utils/bzip2/gzip in minimal images","Clear corrupt caches and let checksummed re-download repair them","Verify archive integrity with -t flags before unpacking","Check URLs actually serve binary content, not error pages"],"tags":["ruby","decompression","archive","brew-shim"],"backgroundTag":"command-not-found","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}