instance method
Gem::Uninstaller#remove
remove(spec)
lib/rubygems/uninstaller.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/rubygems/uninstaller.rb, line 251
def remove(spec)
unless path_ok?(@gem_home, spec) ||
(@user_install && path_ok?(@user_dir, spec))
e = Gem::GemNotInHomeException.new \
"Gem '#{spec.full_name}' is not installed in directory #{@gem_home}"
e.spec = spec
raise e
end
raise Gem::FilePermissionError, spec.base_dir unless
File.writable?(spec.base_dir)
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
gem = spec.cache_file
gem = File.join(spec.cache_dir, "#{old_platform_name}.gem") unless
File.exist? gem
safe_delete { FileUtils.rm_r gem }
begin
Gem::RDoc.new(spec).remove
rescue NameError
end
gemspec = spec.spec_file
unless File.exist? gemspec
gemspec = File.join(File.dirname(gemspec), "#{old_platform_name}.gemspec")
end
safe_delete { FileUtils.rm_r gemspec }
announce_deletion_of(spec)
end
- spec
-
the spec of the gem to be uninstalled
See also
#regenerate_plugins
#remove_all
#plugin_dir_for
#remove_executables
also in
4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0