{"record":{"id":"cb0490493df53376","repo":"ruby/rubygems","slug":"invalid-spec-cache-file-in-local-file","errorCode":null,"errorMessage":"Invalid spec cache file in #{local_file}","messagePattern":"Invalid spec cache file in #(.+?)","errorType":"exception","errorClass":"Gem::Exception","httpStatus":null,"severity":"error","filePath":"lib/rubygems/source.rb","lineNumber":279,"sourceCode":"    retried    = false\n\n    if update_cache?\n      require \"fileutils\"\n      FileUtils.mkdir_p cache_dir\n    end\n\n    spec_dump = fetcher.cache_update_path spec_path, local_file, update_cache?\n\n    Gem.load_safe_marshal\n    begin\n      Gem::NameTuple.from_list Gem::SafeMarshal.safe_load(spec_dump)\n    rescue ArgumentError\n      if update_cache? && !retried\n        FileUtils.rm local_file\n        retried = true\n        retry\n      else\n        raise Gem::Exception.new(\"Invalid spec cache file in #{local_file}\")\n      end\n    end\n  end\n\n  ##\n  # Builds the name tuple list for +type+ from the compact index versions\n  # file. Returns nil when the source does not provide a usable compact\n  # index, so the caller can fall back to the Marshal spec indexes.\n\n  def load_compact_index_specs(type)\n    return unless %w[http https].include?(uri.scheme)\n\n    versions = compact_index_versions\n    return if versions.nil? || versions.empty?\n\n    tuples = []\n\n    versions.each_value do |rows|","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/ruby/rubygems/blob/86cbb817a38ce8477b181c17467a703ded3f2be8/lib/rubygems/source.rb#L261-L297","documentation":"Error \"Invalid spec cache file in #{local_file}\" thrown in ruby/rubygems.","triggerScenarios":"Thrown at lib/rubygems/source.rb:279 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Delete the corrupt spec cache file shown in the message; RubyGems will refetch it"],"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"}