# File lib/rubygems/uninstaller.rb, line 127
  def remove_executables(spec)
    return if spec.nil? or spec.executables.empty?

    list = Gem::Specification.find_all { |s|
      s.name == spec.name && s.version != spec.version
    }

    executables = spec.executables.clone

    list.each do |s|
      s.executables.each do |exe_name|
        executables.delete exe_name
      end
    end

    return if executables.empty?

    executables = executables.map { |exec| formatted_program_filename exec }

    remove = if @force_executables.nil? then
               ask_yes_no("Remove executables:\n" \
                          "\t#{executables.join ', '}\n\n" \
                          "in addition to the gem?",
                          true)
             else
               @force_executables
             end

    unless remove then
      say "Executables and scripts will remain installed."
    else
      bin_dir = @bin_dir || Gem.bindir(spec.base_dir)

      raise Gem::FilePermissionError, bin_dir unless File.writable? bin_dir

      executables.each do |exe_name|
        say "Removing #{exe_name}"

        exe_file = File.join bin_dir, exe_name

        FileUtils.rm_f exe_file
        FileUtils.rm_f "#{exe_file}.bat"
      end
    end
  end