[rubygems/rubygems] Always leave default gem executables around

https://github.com/rubygems/rubygems/commit/775c35e197
This commit is contained in:
David Rodríguez 2024-07-19 11:59:35 +02:00 committed by git
parent ec13ccdf53
commit 3d248b2eb3
2 changed files with 16 additions and 1 deletions

View File

@ -251,7 +251,15 @@ class Gem::Uninstaller
raise Gem::FilePermissionError, spec.base_dir unless
File.writable?(spec.base_dir)
safe_delete { FileUtils.rm_r spec.full_gem_path }
full_gem_path = spec.full_gem_path
exclusions = []
if default_spec_matches?(spec) && spec.executables.any?
exclusions = spec.executables.map {|exe| File.join(spec.bin_dir, exe) }
exclusions << File.dirname(exclusions.last) until exclusions.last == full_gem_path
end
safe_delete { rm_r full_gem_path, exclusions: exclusions }
safe_delete { FileUtils.rm_r spec.extension_dir }
old_platform_name = spec.original_name
@ -378,6 +386,12 @@ class Gem::Uninstaller
private
def rm_r(path, exclusions:)
FileUtils::Entry_.new(path).postorder_traverse do |ent|
ent.remove unless exclusions.include?(ent.path)
end
end
def specification_record
@specification_record ||= @install_dir ? Gem::SpecificationRecord.from_path(@install_dir) : Gem::Specification.specification_record
end

View File

@ -102,6 +102,7 @@ class TestGemCommandsUninstallCommand < Gem::InstallerTestCase
end
assert File.exist? File.join(@gemhome, "bin", "executable")
assert File.exist? File.join(@gemhome, "gems", "z-1", "bin", "executable")
output = @ui.output.split "\n"