{"record":{"id":"b52c474c20d52b02","repo":"ruby/rubygems","slug":"failed-to-parse-gem-specification-out-of-gem-file","errorCode":null,"errorMessage":"Failed to parse gem specification out of gem file","messagePattern":"Failed to parse gem specification out of gem file","errorType":"exception","errorClass":"Gem::Exception","httpStatus":null,"severity":"error","filePath":"lib/rubygems/package/old.rb","lineNumber":155,"sourceCode":"\n  def spec\n    verify\n\n    return @spec if @spec\n\n    yaml = String.new\n\n    @gem.with_read_io do |io|\n      skip_ruby io\n      read_until_dashes io do |line|\n        yaml << line\n      end\n    end\n\n    begin\n      @spec = Gem::Specification.from_yaml yaml\n    rescue Psych::SyntaxError\n      raise Gem::Exception, \"Failed to parse gem specification out of gem file\"\n    end\n  rescue ArgumentError\n    raise Gem::Exception, \"Failed to parse gem specification out of gem file\"\n  end\n\n  ##\n  # Raises an exception if a security policy that verifies data is active.\n  # Old format gems cannot be verified as signed.\n\n  def verify\n    return true unless @security_policy\n\n    raise Gem::Security::Exception,\n          \"old format gems do not contain signatures and cannot be verified\" if\n      @security_policy.verify_data\n\n    true\n  end","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/ruby/rubygems/blob/86cbb817a38ce8477b181c17467a703ded3f2be8/lib/rubygems/package/old.rb#L137-L173","documentation":"Error \"Failed to parse gem specification out of gem file\" thrown in ruby/rubygems.","triggerScenarios":"Thrown at lib/rubygems/package/old.rb:155 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-download the gem; its embedded specification could not be parsed","Rebuild the gem with `gem build foo.gemspec`"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"86cbb817a38ce8477b181c17467a703ded3f2be8","analyzedAt":"2026-08-23T06:27:48.159Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}