Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/rubygems/uninstaller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ 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)
gem_home = @install_dir || Gem.dir
@gem_home = File.exist?(gem_home) ? File.realpath(gem_home) : gem_home
@user_dir = File.exist?(Gem.user_dir) ? File.realpath(Gem.user_dir) : Gem.user_dir
@force_executables = options[:executables]
@force_all = options[:all]
Expand Down
18 changes: 18 additions & 0 deletions test/rubygems/test_gem_uninstaller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,24 @@ def test_uninstall_user_install
assert_same uninstaller, @post_uninstall_hook_arg
end

def test_uninstall_user_install_with_missing_gem_home
FileUtils.rm_rf Gem.dir

Gem::Specification.dirs = [Gem.user_dir]

uninstaller = Gem::Uninstaller.new(@user_spec.name,
executables: true,
user_install: true)

gem_dir = @user_spec.gem_dir

assert_path_exist gem_dir

uninstaller.uninstall

assert_path_not_exist gem_dir
end

def test_uninstall_user_install_with_symlinked_home
pend "Symlinks not supported or not enabled" unless symlink_supported?

Expand Down