[rubygems/rubygems] Fix gem uninstall --user-install
for symlinked HOME's
https://github.com/rubygems/rubygems/commit/7f0706a897
This commit is contained in:
parent
b19693f0ae
commit
5111b3d479
@ -51,6 +51,7 @@ class Gem::Uninstaller
|
|||||||
@version = options[:version] || Gem::Requirement.default
|
@version = options[:version] || Gem::Requirement.default
|
||||||
@install_dir = options[:install_dir]
|
@install_dir = options[:install_dir]
|
||||||
@gem_home = File.realpath(@install_dir || Gem.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_executables = options[:executables]
|
||||||
@force_all = options[:all]
|
@force_all = options[:all]
|
||||||
@force_ignore = options[:ignore]
|
@force_ignore = options[:ignore]
|
||||||
@ -105,7 +106,7 @@ class Gem::Uninstaller
|
|||||||
|
|
||||||
list, other_repo_specs = list.partition do |spec|
|
list, other_repo_specs = list.partition do |spec|
|
||||||
@gem_home == spec.base_dir ||
|
@gem_home == spec.base_dir ||
|
||||||
(@user_install && spec.base_dir == Gem.user_dir)
|
(@user_install && spec.base_dir == @user_dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
list.sort!
|
list.sort!
|
||||||
@ -239,7 +240,7 @@ class Gem::Uninstaller
|
|||||||
|
|
||||||
def remove(spec)
|
def remove(spec)
|
||||||
unless path_ok?(@gem_home, spec) ||
|
unless path_ok?(@gem_home, spec) ||
|
||||||
(@user_install && path_ok?(Gem.user_dir, spec))
|
(@user_install && path_ok?(@user_dir, spec))
|
||||||
e = Gem::GemNotInHomeException.new \
|
e = Gem::GemNotInHomeException.new \
|
||||||
"Gem '#{spec.full_name}' is not installed in directory #{@gem_home}"
|
"Gem '#{spec.full_name}' is not installed in directory #{@gem_home}"
|
||||||
e.spec = spec
|
e.spec = spec
|
||||||
|
@ -453,6 +453,32 @@ create_makefile '#{@spec.name}'
|
|||||||
assert_same uninstaller, @post_uninstall_hook_arg
|
assert_same uninstaller, @post_uninstall_hook_arg
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_uninstall_user_install_with_symlinked_home
|
||||||
|
pend "Symlinks not supported or not enabled" unless symlink_supported?
|
||||||
|
|
||||||
|
Gem::Specification.dirs = [Gem.user_dir]
|
||||||
|
|
||||||
|
symlinked_home = File.join(@tempdir, "new-home")
|
||||||
|
FileUtils.ln_s(Gem.user_home, symlinked_home)
|
||||||
|
|
||||||
|
ENV["HOME"] = symlinked_home
|
||||||
|
Gem.instance_variable_set(:@user_home, nil)
|
||||||
|
Gem.instance_variable_set(:@data_home, nil)
|
||||||
|
|
||||||
|
uninstaller = Gem::Uninstaller.new(@user_spec.name,
|
||||||
|
executables: true,
|
||||||
|
user_install: true,
|
||||||
|
force: true)
|
||||||
|
|
||||||
|
gem_dir = File.join @user_spec.gem_dir
|
||||||
|
|
||||||
|
assert_path_exist gem_dir
|
||||||
|
|
||||||
|
uninstaller.uninstall
|
||||||
|
|
||||||
|
assert_path_not_exist gem_dir
|
||||||
|
end
|
||||||
|
|
||||||
def test_uninstall_wrong_repo
|
def test_uninstall_wrong_repo
|
||||||
Dir.mkdir "#{@gemhome}2"
|
Dir.mkdir "#{@gemhome}2"
|
||||||
Gem.use_paths "#{@gemhome}2", [@gemhome]
|
Gem.use_paths "#{@gemhome}2", [@gemhome]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user