ruby/rubygems · error · Gem::Security::Exception

duplicate files in the package: (#{duplicates.map(&:inspect)

Error message

duplicate files in the package: (#{duplicates.map(&:inspect).join(", ")})

What it means

Error "duplicate files in the package: (#{duplicates.map(&:inspect).join(", ")})" thrown in ruby/rubygems.

Source

Thrown at lib/rubygems/package.rb:734

  ##
  # Verifies the files of the +gem+

  def verify_files(gem)
    gem.each do |entry|
      verify_entry entry
    end

    unless @spec
      raise Gem::Package::FormatError.new "package metadata is missing", @gem
    end

    unless @files.include? "data.tar.gz"
      raise Gem::Package::FormatError.new \
        "package content (data.tar.gz) is missing", @gem
    end

    if (duplicates = @files.group_by {|f| f }.select {|_k,v| v.size > 1 }.map(&:first)) && duplicates.any?
      raise Gem::Security::Exception, "duplicate files in the package: (#{duplicates.map(&:inspect).join(", ")})"
    end
  end

  if RUBY_ENGINE == "truffleruby"
    def copy_stream(src, dst, size) # :nodoc:
      dst.write src.read(size)
    end
  else
    def copy_stream(src, dst, size) # :nodoc:
      IO.copy_stream(src, dst, size)
    end
  end

  def limit_read(io, name, limit)
    bytes = io.read(limit + 1)
    raise Gem::Package::FormatError, "#{name} is too big (over #{limit} bytes)" if bytes.size > limit
    bytes
  end

View on GitHub (pinned to 86cbb817a3)

Solutions

  1. Remove duplicate entries from the gemspec `spec.files` list and rebuild the gem

When it happens

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