Skip to content

Commit

Permalink
[rubygems/rubygems] Make the "auto-user-install" logic easier to follow
Browse files Browse the repository at this point in the history
  • Loading branch information
voxik authored and hsbt committed Dec 12, 2023
1 parent c032dfb commit b37288c
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions lib/rubygems/installer.rb
Expand Up @@ -675,16 +675,20 @@ def process_options # :nodoc:

@build_args = options[:build_args]

@gem_home = @install_dir || Gem.dir

# `--build-root` overrides `--user-install` and auto-user-install
if @build_root.nil? && @install_dir.nil?
if options[:user_install]
@gem_home = Gem.user_dir
elsif !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
@gem_home = @install_dir

unless @gem_home
# `--build-root` overrides `--user-install` and auto-user-install
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))
say "Defaulting to user installation because default installation directory (#{Gem.dir}) is not writable."
@gem_home = Gem.user_dir
end
end

@gem_home ||= Gem.dir
end

# If the user has asked for the gem to be installed in a directory that is
Expand Down

0 comments on commit b37288c

Please sign in to comment.