jdx/mise · error · RuntimeError

failed to decompress #

Error message

failed to decompress #{archive}

What it means

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?.

Solutions

  1. Delete the corrupt cached file under MISE_BREW_CACHE and re-run so it re-downloads
  2. Install the missing decompressor (e.g. `apt-get install xz-utils` or `brew install xz`)
  3. Confirm the URL actually serves the compressed file (curl -sI the URL, check content-type)
  4. Verify the archive manually: `gzip -t <file>` / `xz -t <file>`

Example fix

// environment before
$ which xz  # not found
// after
$ apt-get install -y xz-utils  # or brew install xz
Defensive patterns

Strategy: validation

Validate before calling

raise "missing xz" unless system("which", "xz")
system("xz", "-t", archive.to_s) or raise "corrupt archive #{archive}"

Try / catch

begin
  MiseDownload.unpack(archive, dest)
rescue RuntimeError => e
  warn "unpack failed: #{e.message}; clearing cache"
  FileUtils.rm_f(archive)
end

Prevention

When it happens

Trigger: 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.

Common situations: Interrupted downloads leaving partial caches, tools like xz not installed in minimal container images, downloading an HTML error page saved with a .gz name.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/075d8b95c83f5ee8. Report an issue: GitHub.

Appendix: 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 533346cc37)