diff options
| author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2024-07-19 11:59:35 +0200 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-07-30 14:01:32 +0000 |
| commit | 3d248b2eb3d2b10f9d2ddf614485ceb35089f924 (patch) | |
| tree | ce6399b0916a0a34ef7c6b661c90813ff7ea062d /lib | |
| parent | ec13ccdf53b327957156a2829064270863b0e309 (diff) | |
[rubygems/rubygems] Always leave default gem executables around
https://github.com/rubygems/rubygems/commit/775c35e197
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/rubygems/uninstaller.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb index 214ba53a88..471c29b6e4 100644 --- a/lib/rubygems/uninstaller.rb +++ b/lib/rubygems/uninstaller.rb @@ -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 |
