class Gem::Commands::CleanupCommand

def uninstall_dep(spec)

def uninstall_dep(spec)
  return unless @full.ok_to_remove?(spec.full_name, options[:check_dev])
  if options[:dryrun]
    say "Dry Run Mode: Would uninstall #{spec.full_name}"
    return
  end
  say "Attempting to uninstall #{spec.full_name}"
  uninstall_options = {
    executables: false,
    version: "= #{spec.version}",
  }
  uninstall_options[:user_install] = Gem.user_dir == spec.base_dir
  uninstaller = Gem::Uninstaller.new spec.name, uninstall_options
  begin
    uninstaller.uninstall
  rescue Gem::DependencyRemovalException, Gem::InstallError,
         Gem::GemNotInHomeException, Gem::FilePermissionError => e
    say "Unable to uninstall #{spec.full_name}:"
    say "\t#{e.class}: #{e.message}"
  end
end