diff options
author | Vít Ondruch <[email protected]> | 2023-12-08 16:38:51 +0100 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2023-12-14 20:22:49 +0800 |
commit | 612616925b3d5247748b8df98a13a70f74f8b4c3 (patch) | |
tree | cc91f620eeea3734fad155f586a9ec58a7a20a10 /lib | |
parent | 45b511433d652c46d5652ab295367f41341697af (diff) |
[rubygems/rubygems] Allow "default_user_install" to be overridden.
For Ruby re-distributors, automatic user-install might be the right
default. Therefore printing warning about installing into user directory
is not always desirable. Let the default_user_install method be
customizable.
https://github.com/rubygems/rubygems/commit/2320dba544
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rubygems/defaults.rb | 12 | ||||
-rw-r--r-- | lib/rubygems/installer.rb | 5 |
2 files changed, 13 insertions, 4 deletions
diff --git a/lib/rubygems/defaults.rb b/lib/rubygems/defaults.rb index 1fe6f36f38..00dc5707c3 100644 --- a/lib/rubygems/defaults.rb +++ b/lib/rubygems/defaults.rb @@ -236,6 +236,18 @@ module Gem end ## + # Enables automatic installation into user directory + + def self.default_user_install # :nodoc: + if !ENV.key?("GEM_HOME") && (File.exist?(Gem.dir) && !File.writable?(Gem.dir)) + Gem.ui.say "Defaulting to user installation because default installation directory (#{Gem.dir}) is not writable." + return true + end + + false + end + + ## # Install extensions into lib as well as into the extension directory. def self.install_extension_in_lib # :nodoc: diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index cd1031dc2e..0396e94632 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -684,10 +684,7 @@ class Gem::Installer # * `true`: `--user-install` # * `false`: `--no-user-install` and # * `nil`: option was not specified - if options[:user_install] - @gem_home = Gem.user_dir - elsif options[:user_install].nil? && !ENV.key?("GEM_HOME") && (File.exist?(Gem.dir) && !File.writable?(Gem.dir)) - say "Defaulting to user installation because default installation directory (#{Gem.dir}) is not writable." + if options[:user_install] || (options[:user_install].nil? && Gem.default_user_install) @gem_home = Gem.user_dir end end |