[rubygems/rubygems] If GEM_HOME exists + isn't writable, use --user-install.
https://github.com/rubygems/rubygems/commit/6d20585645
This commit is contained in:
parent
9af5abd23a
commit
7aebe2a52b
@ -185,9 +185,24 @@ module Gem::InstallUpdateOptions
|
|||||||
# Default options for the gem install and update commands.
|
# Default options for the gem install and update commands.
|
||||||
|
|
||||||
def install_update_options
|
def install_update_options
|
||||||
{
|
default_options = {
|
||||||
:document => %w[ri],
|
:document => %w[ri],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# If Gem.paths.home exists, but we can't write to it,
|
||||||
|
# fall back to a user installation.
|
||||||
|
if File.exist?(Gem.paths.home) && !File.writable?(Gem.paths.home)
|
||||||
|
default_options[:user_install] = true
|
||||||
|
|
||||||
|
alert_warning "The default GEM_HOME (#{Gem.paths.home}) is not" \
|
||||||
|
" writable, so rubygems is falling back to installing" \
|
||||||
|
" under your home folder. To get rid of this warning" \
|
||||||
|
" permanently either fix your GEM_HOME folder permissions" \
|
||||||
|
" or add the following to your ~/.gemrc file:\n" \
|
||||||
|
" gem: --user-install"
|
||||||
|
end
|
||||||
|
|
||||||
|
default_options
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -159,6 +159,33 @@ class TestGemInstallUpdateOptions < Gem::InstallerTestCase
|
|||||||
FileUtils.chmod 0o755, @gemhome
|
FileUtils.chmod 0o755, @gemhome
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_auto_user_install_unless_gem_home_writable
|
||||||
|
if Process.uid.zero?
|
||||||
|
pend("test_auto_user_install_unless_gem_home_writable test skipped in root privilege")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
@spec = quick_gem "a" do |spec|
|
||||||
|
util_make_exec spec
|
||||||
|
end
|
||||||
|
|
||||||
|
util_build_gem @spec
|
||||||
|
@gem = @spec.cache_file
|
||||||
|
|
||||||
|
@cmd.handle_options %w[]
|
||||||
|
|
||||||
|
refute @cmd.options[:user_install]
|
||||||
|
|
||||||
|
FileUtils.chmod 0755, @userhome
|
||||||
|
FileUtils.chmod 0000, @gemhome
|
||||||
|
|
||||||
|
Gem.use_paths @gemhome, @userhome
|
||||||
|
|
||||||
|
@cmd.install_update_options.include?(:user_install)
|
||||||
|
ensure
|
||||||
|
FileUtils.chmod 0755, @gemhome
|
||||||
|
end
|
||||||
|
|
||||||
def test_vendor
|
def test_vendor
|
||||||
vendordir(File.join(@tempdir, "vendor")) do
|
vendordir(File.join(@tempdir, "vendor")) do
|
||||||
@cmd.handle_options %w[--vendor]
|
@cmd.handle_options %w[--vendor]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user