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

trust directory #{@dir} is not a directory

Error message

trust directory #{@dir} is not a directory

What it means

Error "trust directory #{@dir} is not a directory" thrown in ruby/rubygems.

Source

Thrown at lib/rubygems/security/trust_dir.rb:108

    verify

    destination = cert_path certificate

    File.open destination, "wb", 0o600 do |io|
      io.write certificate.to_pem
      io.chmod(@permissions[:trusted_cert])
    end
  end

  ##
  # Make sure the trust directory exists.  If it does exist, make sure it's
  # actually a directory.  If not, then create it with the appropriate
  # permissions.

  def verify
    require "fileutils"
    if File.exist? @dir
      raise Gem::Security::Exception,
        "trust directory #{@dir} is not a directory" unless
          File.directory? @dir

      FileUtils.chmod 0o700, @dir
    else
      FileUtils.mkdir_p @dir, mode: @permissions[:trust_dir]
    end
  end
end

View on GitHub (pinned to 86cbb817a3)

Solutions

  1. Point the trust directory option at an existing directory (create it first)

When it happens

Trigger: Thrown at lib/rubygems/security/trust_dir.rb:108 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/1a70ac1a64a4fa4e. Report an issue: GitHub.