ruby/rubygems · error · ArgumentError

uri scheme is invalid: #{uri.scheme.inspect}

Error message

uri scheme is invalid: #{uri.scheme.inspect}

What it means

Error "uri scheme is invalid: #{uri.scheme.inspect}" thrown in ruby/rubygems.

Source

Thrown at lib/rubygems/remote_fetcher.rb:259

      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}" }

    data = send method, uri, mtime, head

    if data && !head && uri.to_s.end_with?(".gz")
      begin
        data = Gem::Util.gunzip data
      rescue Zlib::GzipFile::Error
        raise FetchError.new("server did not return a valid file", uri)
      end
    end

    data
  rescue Gem::Timeout::Error, IOError, SocketError, SystemCallError,
         *(OpenSSL::SSL::SSLError if Gem::HAVE_OPENSSL) => e
    raise FetchError.new("#{e.class}: #{e}", uri)
  end

  def fetch_s3(uri, mtime = nil, head = false)

View on GitHub (pinned to 86cbb817a3)

Solutions

  1. Fix the source URI to use a valid scheme (http:// or https://)

When it happens

Trigger: Thrown at lib/rubygems/remote_fetcher.rb:259 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/60f9058092351f52. Report an issue: GitHub.