[rubygems/rubygems] Try a different approach for fallback to --user-install.

https://github.com/rubygems/rubygems/commit/13e0704c40
This commit is contained in:
Ellen Marie Dash 2023-03-31 22:24:28 -04:00 committed by git
parent 7aebe2a52b
commit 4925570de2
2 changed files with 14 additions and 16 deletions

View File

@ -185,24 +185,9 @@ module Gem::InstallUpdateOptions
# Default options for the gem install and update commands.
def install_update_options
default_options = {
{
: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
##

View File

@ -32,6 +32,19 @@ class Gem::PathSupport
@home = expand(@home)
# If @home (aka Gem.paths.home) exists, but we can't write to it,
# fall back to Gem.user_dir (the directory used for user installs).
if File.exist?(@home) && !File.writable?(@home)
warn "The default GEM_HOME (#{@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: --install-dir #{Gem.user_dir}"
@home = Gem.user_dir
end
@path = split_gem_path env["GEM_PATH"], @home
@spec_cache_dir = env["GEM_SPEC_CACHE"] || Gem.default_spec_cache_dir