ruby/rubygems · error · Gem::SafeMarshal::Visitors::ToRuby::FormatError

Expected symbol or symbol link, got #{element.inspect} @ #{f

Error message

Expected symbol or symbol link, got #{element.inspect} @ #{formatted_stack.join(".")}

What it means

Error "Expected symbol or symbol link, got #{element.inspect} @ #{formatted_stack.join(".")}" thrown in ruby/rubygems.

Source

Thrown at lib/rubygems/safe_marshal/visitors/to_ruby.rb:343

        when Elements::Symbol
          sym = element.name.to_sym
          @symbols << sym
          sym
        when Elements::SymbolLink
          visit_Gem_SafeMarshal_Elements_SymbolLink(element)
        end
      end

      # This is a hot method, so avoid respond_to? checks on every invocation
      if :read.respond_to?(:name)
        def resolve_symbol_name(element)
          case element
          when Elements::Symbol
            element.name
          when Elements::SymbolLink
            visit_Gem_SafeMarshal_Elements_SymbolLink(element).name
          else
            raise FormatError, "Expected symbol or symbol link, got #{element.inspect} @ #{formatted_stack.join(".")}"
          end
        end
      else
        def resolve_symbol_name(element)
          case element
          when Elements::Symbol
            element.name
          when Elements::SymbolLink
            visit_Gem_SafeMarshal_Elements_SymbolLink(element).to_s
          else
            raise FormatError, "Expected symbol or symbol link, got #{element.inspect} @ #{formatted_stack.join(".")}"
          end
        end
      end

      def register_object(o)
        @objects << o
        o

View on GitHub (pinned to 86cbb817a3)

Solutions

  1. The marshal data is corrupt (bad symbol entry); re-download the gem or metadata file

When it happens

Trigger: Thrown at lib/rubygems/safe_marshal/visitors/to_ruby.rb:343 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/c545c9eac4d9d32f. Report an issue: GitHub.