lib/rubygems/commands/cleanup_command.rb in rubygems-update-1.8.6 vs lib/rubygems/commands/cleanup_command.rb in rubygems-update-1.8.7
- old
+ new
@@ -59,10 +59,12 @@
deplist = Gem::DependencyList.new
gems_to_cleanup.uniq.each do |spec| deplist.add spec end
deps = deplist.strongly_connected_components.flatten.reverse
+ original_path = Gem.path
+
deps.each do |spec|
if options[:dryrun] then
say "Dry Run Mode: Would uninstall #{spec.full_name}"
else
say "Attempting to uninstall #{spec.full_name}"
@@ -72,23 +74,24 @@
uninstall_options = {
:executables => false,
:version => "= #{spec.version}",
}
- if Gem.user_dir == spec.base_dir then
- uninstall_options[:install_dir] = spec.base_dir
- end
+ 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 => e
+ Gem::GemNotInHomeException, Gem::FilePermissionError => e
say "Unable to uninstall #{spec.full_name}:"
say "\t#{e.class}: #{e.message}"
end
end
+
+ # Restore path Gem::Uninstaller may have change
+ Gem.use_paths(*original_path)
end
say "Clean Up Complete"
end