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

redirecting but no redirect location was given

Error message

redirecting but no redirect location was given

What it means

Error "redirecting but no redirect location was given" thrown in ruby/rubygems.

Source

Thrown at lib/rubygems/remote_fetcher.rb:230

  ##
  # HTTP Fetcher. Dispatched by +fetch_path+. Use it instead.

  def fetch_http(uri, last_modified = nil, head = false, depth = 0)
    fetch_type = head ? Gem::Net::HTTP::Head : Gem::Net::HTTP::Get
    response   = request uri, fetch_type, last_modified do |req|
      headers.each {|k,v| req.add_field(k,v) }
    end

    case response
    when Gem::Net::HTTPOK, Gem::Net::HTTPNotModified then
      response.uri = uri
      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

  ##

View on GitHub (pinned to 86cbb817a3)

Solutions

  1. The server sent a redirect without a Location header; contact the gem source operator or switch to the canonical source URL

When it happens

Trigger: Thrown at lib/rubygems/remote_fetcher.rb:230 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/0408dbcf165997e7. Report an issue: GitHub.