lib/rubygems/commands/cleanup_command.rb in rubygems-update-3.5.20 vs lib/rubygems/commands/cleanup_command.rb in rubygems-update-3.5.21

- old
+ new

@@ -36,12 +36,10 @@ @candidate_gems = nil @default_gems = [] @full = nil @gems_to_cleanup = nil - @original_home = nil - @original_path = nil @primary_gems = nil end def arguments # :nodoc: "GEMNAME name of gem to cleanup" @@ -93,13 +91,10 @@ "Skipped default gems: #{skipped.join ", "}" end end def clean_gems - @original_home = Gem.dir - @original_path = Gem.path - get_primary_gems get_candidate_gems get_gems_to_cleanup @full = Gem::DependencyList.from_specs @@ -110,12 +105,10 @@ deps = deplist.strongly_connected_components.flatten deps.reverse_each do |spec| uninstall_dep spec end - - Gem::Specification.reset end def get_candidate_gems @candidate_gems = if options[:args].empty? Gem::Specification.to_a @@ -131,11 +124,11 @@ @primary_gems[spec.name].version != spec.version end default_gems, gems_to_cleanup = gems_to_cleanup.partition(&:default_gem?) - uninstall_from = options[:user_install] ? Gem.user_dir : @original_home + uninstall_from = options[:user_install] ? Gem.user_dir : Gem.dir gems_to_cleanup = gems_to_cleanup.select do |spec| spec.base_dir == uninstall_from end @@ -179,10 +172,7 @@ rescue Gem::DependencyRemovalException, Gem::InstallError, Gem::GemNotInHomeException, Gem::FilePermissionError => e say "Unable to uninstall #{spec.full_name}:" say "\t#{e.class}: #{e.message}" end - ensure - # Restore path Gem::Uninstaller may have changed - Gem.use_paths @original_home, *@original_path end end