ruby/rubygems · error · Gem::Package::SymlinkError

installing symlink '%s' pointing to parent path %s of %s is

Error message

installing symlink '%s' pointing to parent path %s of %s is not allowed

What it means

Error "installing symlink '%s' pointing to parent path %s of %s is not allowed" thrown in ruby/rubygems.

Source

Thrown at lib/rubygems/package.rb:438

  def extract_tar_gz(io, destination_dir, pattern = "*") # :nodoc:
    destination_dir = File.realpath(destination_dir)

    directories = []
    symlinks = []

    open_tar_gz io do |tar|
      tar.each do |entry|
        full_name = entry.full_name
        next unless File.fnmatch pattern, full_name, File::FNM_DOTMATCH

        destination = install_location full_name, destination_dir

        if entry.symlink?
          link_target = entry.header.linkname
          real_destination = link_target.start_with?("/") ? link_target : File.expand_path(link_target, File.dirname(destination))

          raise Gem::Package::SymlinkError.new(full_name, real_destination, destination_dir) unless
            normalize_path(real_destination).start_with? normalize_path(destination_dir + "/")

          symlinks << [full_name, link_target, destination, real_destination]
        end

        mkdir =
          if entry.directory?
            destination
          else
            File.dirname destination
          end

        unless directories.include?(mkdir)
          FileUtils.mkdir_p mkdir, mode: dir_mode ? 0o755 : (entry.header.mode if entry.directory?)
          directories << mkdir
        end

        verify_extraction_dir mkdir, destination_dir

View on GitHub (pinned to 86cbb817a3)

Solutions

  1. Do not install this package: it contains a symlink escaping the install directory
  2. If you built the gem, remove the offending symlink and rebuild

When it happens

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