ruby/rubygems · error · ArgumentError
Malformed version number string #{version}
Error message
Malformed version number string #{version} What it means
Error "Malformed version number string #{version}" thrown in ruby/rubygems.
Source
Thrown at lib/rubygems/version.rb:228
end
@@all = {}
@@bump = {}
@@release = {}
def self.new(version) # :nodoc:
return super unless self == Gem::Version
@@all[version] ||= super
end
##
# Constructs a Version from the +version+ string. A version string is a
# series of digits or ASCII letters separated by dots.
def initialize(version)
unless self.class.correct?(version)
raise ArgumentError, "Malformed version number string #{version}"
end
# If version is an empty string convert it to 0
version = 0 if version.nil? || (version.is_a?(String) && /\A\s*\Z/.match?(version))
@version = version.to_s
# optimization to avoid allocation when given an integer, since we know
# it's to_s won't have any spaces or dashes
unless version.is_a?(Integer)
@version = @version.strip
@version.gsub!("-",".pre.")
end
@version = -@version
@segments = nil
@sort_key = compute_sort_key
end
View on GitHub (pinned to 86cbb817a3)
Solutions
- Use a valid version string: digits separated by dots (e.g. '1.2.3'), optionally with a letter prerelease segment
When it happens
Trigger: Thrown at lib/rubygems/version.rb:228 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/d3901d2b7010dd91.
Report an issue: GitHub.