ruby/rubygems · error · Gem::RemoteFetcher::FetchError

Bad response #{error_detail} #{response.code}

Error message

Bad response #{error_detail} #{response.code}

What it means

Error "Bad response #{error_detail} #{response.code}" thrown in ruby/rubygems.

Source

Thrown at lib/rubygems/remote_fetcher.rb:242

      head ? response : response.body
    when Gem::Net::HTTPMovedPermanently, Gem::Net::HTTPFound, Gem::Net::HTTPSeeOther,
         Gem::Net::HTTPTemporaryRedirect then
      raise FetchError.new("too many redirects", uri) if depth > 10

      unless location = response["Location"]
        raise FetchError.new("redirecting but no redirect location was given", uri)
      end
      location = Gem::Uri.new location

      if https?(uri) && !https?(location)
        raise FetchError.new("redirecting to non-https resource: #{location}", uri)
      end

      fetch_http(location, last_modified, head, depth + 1)
    else
      custom_error = response["X-Error-Message"]
      error_detail = custom_error || response.message
      raise FetchError.new("Bad response #{error_detail} #{response.code}", uri)
    end
  end

  alias_method :fetch_https, :fetch_http

  ##
  # Downloads +uri+ and returns it as a String.

  def fetch_path(uri, mtime = nil, head = false)
    uri = Gem::Uri.new uri

    method = {
      "http" => "fetch_http",
      "https" => "fetch_http",
      "s3" => "fetch_s3",
      "file" => "fetch_file",
    }.fetch(uri.scheme) { raise ArgumentError, "uri scheme is invalid: #{uri.scheme.inspect}" }

View on GitHub (pinned to 86cbb817a3)

Solutions

  1. Retry the command; transient server errors often clear
  2. Check proxy settings and the status of the gem source

When it happens

Trigger: Thrown at lib/rubygems/remote_fetcher.rb:242 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/6097b6de2a7ffcd4. Report an issue: GitHub.