ruby/rubygems · error · Gem::Exception

Failed to find end of Ruby script while reading gem

Error message

Failed to find end of Ruby script while reading gem

What it means

Error "Failed to find end of Ruby script while reading gem" thrown in ruby/rubygems.

Source

Thrown at lib/rubygems/package/old.rb:132

  def read_until_dashes(io) # :nodoc:
    while (line = io.gets) && line.chomp.strip != "---" do
      yield line if block_given?
    end
  end

  ##
  # Skips the Ruby self-install header in +io+.

  def skip_ruby(io) # :nodoc:
    loop do
      line = io.gets

      return if line.chomp == "__END__"
      break unless line
    end

    raise Gem::Exception, "Failed to find end of Ruby script while reading gem"
  end

  ##
  # The specification for this gem

  def spec
    verify

    return @spec if @spec

    yaml = String.new

    @gem.with_read_io do |io|
      skip_ruby io
      read_until_dashes io do |line|
        yaml << line
      end
    end

View on GitHub (pinned to 86cbb817a3)

Solutions

  1. The gem file is truncated or malformed; re-download it
  2. Rebuild old-format gems with a current RubyGems

When it happens

Trigger: Thrown at lib/rubygems/package/old.rb:132 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/e869b446c6d00d8c. Report an issue: GitHub.