aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rubygems
diff options
context:
space:
mode:
authorEllen Marie Dash <me@duckie.co>2022-01-31 23:20:58 -0500
committergit <svn-admin@ruby-lang.org>2023-10-11 19:07:26 +0000
commit7aebe2a52bac2a925c475c511640ad13a7d20490 (patch)
treec9f44963bf299a9bacb2dd19c05c6e6bf1fced54 /lib/rubygems
parent9af5abd23acf567f5a5a88c3dbdd7676342256fa (diff)
downloadruby-7aebe2a52bac2a925c475c511640ad13a7d20490.tar.gz
[rubygems/rubygems] If GEM_HOME exists + isn't writable, use --user-install.
https://github.com/rubygems/rubygems/commit/6d20585645
Diffstat (limited to 'lib/rubygems')
-rw-r--r--lib/rubygems/install_update_options.rb17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/rubygems/install_update_options.rb b/lib/rubygems/install_update_options.rb
index 5c7289426e..15b0860fc9 100644
--- a/lib/rubygems/install_update_options.rb
+++ b/lib/rubygems/install_update_options.rb
@@ -185,9 +185,24 @@ 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
##