ruby/rubygems · error · Gem::RemoteFetcher::FetchError
server did not return a valid file
Error message
server did not return a valid file
What it means
Error "server did not return a valid file" thrown in ruby/rubygems.
Source
Thrown at lib/rubygems/remote_fetcher.rb:267
# 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)
begin
public_uri = s3_uri_signer(uri, head ? "HEAD" : "GET").sign
rescue Gem::S3URISigner::ConfigurationError, Gem::S3URISigner::InstanceProfileError => e
raise FetchError.new(e.message, "s3://#{uri.host}")
end
fetch_https public_uri, mtime, head
end
View on GitHub (pinned to 86cbb817a3)
Solutions
- Re-fetch from the source; the response was not a valid gem/spec file
- Check that the URL actually serves gems (not an HTML error page)
When it happens
Trigger: Thrown at lib/rubygems/remote_fetcher.rb:267 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/be099cdb4074299d.
Report an issue: GitHub.