diff options
author | David RodrÃguez <[email protected]> | 2023-12-14 16:50:50 +0100 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2023-12-16 10:07:05 +0800 |
commit | 0ff34aa13e9340871d5aeb339b5d86c52c7c2ca6 (patch) | |
tree | d84e9a2e2c8404bed39c08411f61b3058634a278 /lib | |
parent | 299eb8d1179ed7bea49c50b0fa003bf0724f6fb4 (diff) |
[rubygems/rubygems] More improves to default gem home selection for installation
https://github.com/rubygems/rubygems/commit/966daf7d42
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rubygems/installer.rb | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index 0396e94632..8f6f9a5aa8 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -664,6 +664,7 @@ class Gem::Installer @env_shebang = options[:env_shebang] @force = options[:force] @install_dir = options[:install_dir] + @user_install = options[:user_install] @ignore_dependencies = options[:ignore_dependencies] @format_executable = options[:format_executable] @wrappers = options[:wrappers] @@ -675,22 +676,7 @@ class Gem::Installer @build_args = options[:build_args] - @gem_home = @install_dir - - 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] || (options[:user_install].nil? && Gem.default_user_install) - @gem_home = Gem.user_dir - end - end - - @gem_home ||= Gem.dir - end + @gem_home = @install_dir || user_install_dir || Gem.dir # If the user has asked for the gem to be installed in a directory that is # the system gem directory, then use the system bin directory, else create @@ -986,6 +972,19 @@ TEXT private + def user_install_dir + # never install to user home in --build-root mode + return unless @build_root.nil? + + # Please note that @user_install might have three states: + # * `true`: `--user-install` + # * `false`: `--no-user-install` and + # * `nil`: option was not specified + if @user_install || (@user_install.nil? && Gem.default_user_install) + Gem.user_dir + end + end + def build_args @build_args ||= begin require_relative "command" |