class Bundler::RubyGemsGemInstaller

def build_extensions

def build_extensions
  extension_cache_path = options[:bundler_extension_cache_path]
  unless extension_cache_path && extension_dir = spec.extension_dir
    require "shellwords" # compensate missing require in rubygems before version 3.2.25
    return super
  end
  extension_dir = Pathname.new(extension_dir)
  build_complete = SharedHelpers.filesystem_access(extension_cache_path.join("gem.build_complete"), :read, &:file?)
  if build_complete && !options[:force]
    SharedHelpers.filesystem_access(extension_dir.parent, &:mkpath)
    SharedHelpers.filesystem_access(extension_cache_path) do
      FileUtils.cp_r extension_cache_path, spec.extension_dir
    end
  else
    require "shellwords" # compensate missing require in rubygems before version 3.2.25
    super
    if extension_dir.directory? # not made for gems without extensions
      SharedHelpers.filesystem_access(extension_cache_path.parent, &:mkpath)
      SharedHelpers.filesystem_access(extension_cache_path) do
        FileUtils.cp_r extension_dir, extension_cache_path
      end
    end
  end
end