Skip to content

Commit 1a9df20

Browse files
authored
Merge pull request #7243 from voxik/auto-user-install-override
Allow "auto-user-install" to be overridden.
2 parents 3285550 + 2320dba commit 1a9df20

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

lib/rubygems/defaults.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,18 @@ def self.default_cert_path
235235
default_cert_path
236236
end
237237

238+
##
239+
# Enables automatic installation into user directory
240+
241+
def self.default_user_install # :nodoc:
242+
if !ENV.key?("GEM_HOME") && (File.exist?(Gem.dir) && !File.writable?(Gem.dir))
243+
Gem.ui.say "Defaulting to user installation because default installation directory (#{Gem.dir}) is not writable."
244+
return true
245+
end
246+
247+
false
248+
end
249+
238250
##
239251
# Install extensions into lib as well as into the extension directory.
240252

lib/rubygems/installer.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -684,10 +684,7 @@ def process_options # :nodoc:
684684
# * `true`: `--user-install`
685685
# * `false`: `--no-user-install` and
686686
# * `nil`: option was not specified
687-
if options[:user_install]
688-
@gem_home = Gem.user_dir
689-
elsif options[:user_install].nil? && !ENV.key?("GEM_HOME") && (File.exist?(Gem.dir) && !File.writable?(Gem.dir))
690-
say "Defaulting to user installation because default installation directory (#{Gem.dir}) is not writable."
687+
if options[:user_install] || (options[:user_install].nil? && Gem.default_user_install)
691688
@gem_home = Gem.user_dir
692689
end
693690
end

0 commit comments

Comments
 (0)