ruby/rubygems · error · Gem::SafeMarshal::Visitors::ToRuby::UnsupportedError
Unsupported user-defined class #{klass} in marshal stream @
Error message
Unsupported user-defined class #{klass} in marshal stream @ #{stack.join(".")} What it means
Error "Unsupported user-defined class #{klass} in marshal stream @ #{stack.join(".")}" thrown in ruby/rubygems.
Source
Thrown at lib/rubygems/safe_marshal/visitors/to_ruby.rb:192
def visit_Gem_SafeMarshal_Elements_Object(o)
register_object(resolve_class(o.name).allocate)
end
def visit_Gem_SafeMarshal_Elements_ObjectLink(o)
@objects.fetch(o.offset)
end
def visit_Gem_SafeMarshal_Elements_SymbolLink(o)
@symbols.fetch(o.offset)
end
SAFE_USER_DEFINED_CLASSES = [::Time, ::Gem::Specification].freeze
private_constant :SAFE_USER_DEFINED_CLASSES
def visit_Gem_SafeMarshal_Elements_UserDefined(o)
klass = resolve_class(o.name)
unless SAFE_USER_DEFINED_CLASSES.include?(klass)
raise UnsupportedError.new("Unsupported user-defined class #{klass} in marshal stream", stack: formatted_stack)
end
register_object(call_method(klass, :_load, o.binary_string))
end
def visit_Gem_SafeMarshal_Elements_UserMarshal(o)
klass = resolve_class(o.name)
compat = COMPAT_CLASSES.fetch(klass, nil)
idx = @objects.size
object = register_object(call_method(compat || klass, :allocate))
push_stack :data
ret = call_method(object, :marshal_load, visit(o.data))
if compat
object = @objects[idx] = ret
end
objectView on GitHub (pinned to 86cbb817a3)
Solutions
- The metadata embeds an unsupported user-defined class; rebuild the gem with a current RubyGems
When it happens
Trigger: Thrown at lib/rubygems/safe_marshal/visitors/to_ruby.rb:192 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/7095027f41d276e5.
Report an issue: GitHub.