From 402fd96ddc401cf35bced8d394c44df98d6fc466 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ondruch?= Date: Tue, 12 Dec 2023 14:38:45 +0100 Subject: [rubygems/rubygems] Make sure `--no-user-install` is respected for auto user installation The `options[:user_install]` might have three states: * `true`: `--user-install` * `false`: `--no-user-install` and * `nil`: option was not specified However, this had not been respected previously and the `false` and `nil` were treated the same. This could lead to auto user installation despite `--no-user-install` being specified on the command line. Fixes https://github.com/rubygems/rubygems/pull/7237 https://github.com/rubygems/rubygems/commit/9281545474 --- lib/rubygems/installer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index b4375c3f1c..acb49f510a 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -682,7 +682,7 @@ class Gem::Installer if @build_root.nil? if options[:user_install] @gem_home = Gem.user_dir - elsif !ENV.key?("GEM_HOME") && (File.exist?(Gem.dir) && !File.writable?(Gem.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." @gem_home = Gem.user_dir end -- cgit v1.2.3