ruby/rubygems · error · Gem::Exception

Failed to parse gem specification out of gem file

Error message

Failed to parse gem specification out of gem file

What it means

Error "Failed to parse gem specification out of gem file" thrown in ruby/rubygems.

Source

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

  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

    begin
      @spec = Gem::Specification.from_yaml yaml
    rescue Psych::SyntaxError
      raise Gem::Exception, "Failed to parse gem specification out of gem file"
    end
  rescue ArgumentError
    raise Gem::Exception, "Failed to parse gem specification out of gem file"
  end

  ##
  # Raises an exception if a security policy that verifies data is active.
  # Old format gems cannot be verified as signed.

  def verify
    return true unless @security_policy

    raise Gem::Security::Exception,
          "old format gems do not contain signatures and cannot be verified" if
      @security_policy.verify_data

    true
  end

View on GitHub (pinned to 86cbb817a3)

Solutions

  1. Re-download the gem; its embedded specification could not be parsed
  2. Rebuild the gem with `gem build foo.gemspec`

When it happens

Trigger: Thrown at lib/rubygems/package/old.rb:155 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of ruby/rubygems@86cbb817a3 (2026-08-23). Data as JSON: /api/errors/b52c474c20d52b02. Report an issue: GitHub.