diff options
author | Vít Ondruch <vondruch@redhat.com> | 2023-10-20 18:01:14 +0200 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2023-11-08 09:04:28 +0900 |
commit | 42cf1307c3e110f5d01b74f16cbdd0f83e183abe (patch) | |
tree | c63c85a431739518f25f0fefa36c11d8c677d910 /lib/rubygems | |
parent | acd428c823ea70faa12edf09af303b4f843d3691 (diff) | |
download | ruby-42cf1307c3e110f5d01b74f16cbdd0f83e183abe.tar.gz |
[rubygems/rubygems] Make the user installation less exceptional
The main purpose is to put handling of user installation into the same
place as e.g. handling the --build-root option handling. There is no
reason why the --build-root option should not prefix also paths used for
user installation.
Please note that the `util_installer` in
`test_generate_plugins_with_user_install` enforced the `:install_dir`,
which is against what user install is about.
https://github.com/rubygems/rubygems/commit/0b10cb41aa
Diffstat (limited to 'lib/rubygems')
-rw-r--r-- | lib/rubygems/installer.rb | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index e5df0b4e71..329e90cdf8 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -189,12 +189,6 @@ class Gem::Installer @package.prog_mode = options[:prog_mode] @package.data_mode = options[:data_mode] - if options[:user_install] - @gem_home = Gem.user_dir - @bin_dir = Gem.bindir gem_home unless options[:bin_dir] - @plugins_dir = Gem.plugindir(gem_home) - end - if @gem_home == Gem.user_dir # If we get here, then one of the following likely happened: # - `--user-install` was specified @@ -673,22 +667,27 @@ class Gem::Installer @env_shebang = options[:env_shebang] @force = options[:force] @install_dir = options[:install_dir] - @gem_home = options[:install_dir] || Gem.dir - @plugins_dir = Gem.plugindir(@gem_home) @ignore_dependencies = options[:ignore_dependencies] @format_executable = options[:format_executable] @wrappers = options[:wrappers] @only_install_dir = options[:only_install_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 - # (or use) a new bin dir under the gem_home. - @bin_dir = options[:bin_dir] || Gem.bindir(gem_home) + @bin_dir = options[:bin_dir] @development = options[:development] @build_root = options[:build_root] @build_args = options[:build_args] + @gem_home = @install_dir + @gem_home ||= options[:user_install] ? Gem.user_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 + # (or use) a new bin dir under the gem_home. + @bin_dir ||= Gem.bindir(@gem_home) + + @plugins_dir = Gem.plugindir(@gem_home) + unless @build_root.nil? @bin_dir = File.join(@build_root, @bin_dir.gsub(/^[a-zA-Z]:/, "")) @gem_home = File.join(@build_root, @gem_home.gsub(/^[a-zA-Z]:/, "")) |