ruby/rubygems · error · Gem::CompactIndexClient::Error

invalid gzip response while fetching /#{remote_path}

Error message

invalid gzip response while fetching /#{remote_path}

What it means

Error "invalid gzip response while fetching /#{remote_path}" thrown in ruby/rubygems.

Source

Thrown at lib/rubygems/compact_index_client/updater.rb:33

  # Updates the cached files on disk, keeping them in sync with the server
  # using conditional requests (ETag) and ranged requests where possible.
  class Updater
    class MismatchedChecksumError < Error
      def initialize(path, message)
        super "The checksum of /#{path} does not match the checksum provided by the server! Something is wrong. #{message}"
      end
    end

    def initialize(fetcher)
      @fetcher = fetcher
    end

    def update(remote_path, local_path, etag_path)
      append(remote_path, local_path, etag_path) || replace(remote_path, local_path, etag_path)
    rescue CacheFile::DigestMismatchError => e
      raise MismatchedChecksumError.new(remote_path, e.message)
    rescue Zlib::GzipFile::Error
      raise Error, "invalid gzip response while fetching /#{remote_path}"
    end

    private

    def append(remote_path, local_path, etag_path)
      return false unless local_path.file? && local_path.size.nonzero?

      CacheFile.copy(local_path) do |file|
        etag = etag_path.read.tap(&:chomp!) if etag_path.file?

        # Subtract a byte to ensure the range won't be empty.
        # Avoids 416 (Range Not Satisfiable) responses.
        response = @fetcher.call(remote_path, request_headers(etag, file.size - 1))
        break true if response.is_a?(Gem::Net::HTTPNotModified)

        file.digests = parse_digests(response)
        # server may ignore Range and return the full response
        if response.is_a?(Gem::Net::HTTPPartialContent)

View on GitHub (pinned to 86cbb817a3)

When it happens

Trigger: Thrown at lib/rubygems/compact_index_client/updater.rb:33 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of ruby/rubygems@86cbb817a3 (2026-08-23). Data as JSON: /api/errors/48e51035e4bdc0fe. Report an issue: GitHub.