diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index acb49f510a5ed4..cd1031dc2e2d20 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -680,6 +680,10 @@ def process_options # :nodoc: unless @gem_home # `--build-root` overrides `--user-install` and auto-user-install if @build_root.nil? + # Please note that `options[:user_install]` might have three states: + # * `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))