Gem::Uninstaller.new
# File tmp/rubies/ruby-4.0.0/lib/rubygems/uninstaller.rb, line 63
def initialize(gem, options = {})
@gem = gem
@version = options[:version] || Gem::Requirement.default
@install_dir = options[:install_dir]
@gem_home = File.realpath(@install_dir || Gem.dir)
@user_dir = File.exist?(Gem.user_dir) ? File.realpath(Gem.user_dir) : Gem.user_dir
@force_executables = options[:executables]
@force_all = options[:all]
@force_ignore = options[:ignore]
@bin_dir = options[:bin_dir]
@format_executable = options[:format_executable]
@abort_on_dependent = options[:abort_on_dependent]
@check_dev = options[:check_dev]
if options[:force]
@force_all = true
@force_ignore = true
end
# only add user directory if install_dir is not set
@user_install = false
@user_install = options[:user_install] unless @install_dir
# Optimization: populated during #uninstall
@default_specs_matching_uninstall_params = []
end
Constructs an uninstaller that will uninstall gem named gem. options is a Hash with the following keys:
- :version
-
Version requirement for the gem to uninstall. If not specified, uses
Gem::Requirement.default. - :install_dir
-
The directory where the gem is installed. If not specified, uses
Gem.dir. - :executables
-
Whether executables should be removed without confirmation or not. If nil, asks the user explicitly.
- :all
-
If more than one version matches the requirement, whether to forcefully remove all matching versions or ask the user to select specific matching versions that should be removed.
- :ignore
-
Ignore broken dependency checks when uninstalling.
- :bin_dir
-
Directory containing executables to remove. If not specified, uses
Gem.bindir. - :format_executable
-
In order to find executables to be removed, format executable names using
Gem::Installer.exec_format. - :abort_on_dependent
-
Directly abort uninstallation if dependencies would be broken, rather than asking the user for confirmation.
- :check_dev
-
When checking if uninstalling gem would leave broken dependencies around, also consider development dependencies.
- :force
-
Set both :all and :ignore to true for forced uninstallation.
- :user_install
-
Uninstall from user gem directory instead of system directory.