ruby/rubygems · error · Gem::Exception
malformed spec name: #{spec_file_name.inspect}
Error message
malformed spec name: #{spec_file_name.inspect} What it means
Error "malformed spec name: #{spec_file_name.inspect}" thrown in ruby/rubygems.
Source
Thrown at lib/rubygems/source.rb:116
File.stat(Gem.user_home).uid == Process.uid
rescue Errno::ENOENT
false
end
end
##
# Fetches a specification for the given Gem::NameTuple.
def fetch_spec(name_tuple)
fetcher = Gem::RemoteFetcher.fetcher
spec_file_name = name_tuple.spec_name
# The name tuple comes from a remote index and is not otherwise
# validated, so refuse anything that would escape the spec cache
# directory when used as a path component.
if File.basename(spec_file_name) != spec_file_name
raise Gem::Exception, "malformed spec name: #{spec_file_name.inspect}"
end
source_uri = enforce_trailing_slash(uri) + "#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}"
cache_dir = cache_dir source_uri
local_spec = File.join cache_dir, spec_file_name
if File.exist? local_spec
spec = Gem.read_binary local_spec
Gem.load_safe_marshal
spec = begin
Gem::SafeMarshal.safe_load(spec)
rescue StandardError
nil
end
return spec if spec
endView on GitHub (pinned to 86cbb817a3)
Solutions
- Rename the spec file to the '<name>-<version>.gemspec' format so it can be parsed
When it happens
Trigger: Thrown at lib/rubygems/source.rb:116 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of ruby/rubygems@86cbb817a3 (2026-08-23).
Data as JSON: /api/errors/d74ac9006d0bf102.
Report an issue: GitHub.