diff options
author | Ellen Marie Dash <[email protected]> | 2023-09-29 21:48:44 -0400 |
---|---|---|
committer | git <[email protected]> | 2023-10-11 19:07:27 +0000 |
commit | ee9cb86bb49db0fe1613a5121a89587630506780 (patch) | |
tree | 92f5d31587fe57558a055dbce601875e8886dfaf /lib/rubygems/path_support.rb | |
parent | 0b9b07a717a31b7f3c87a9097c9fe1833efe9b1d (diff) |
[rubygems/rubygems] Split out Gem::PathSupport#default_home_dir to fix "bundle doctor" specs.
https://github.com/rubygems/rubygems/commit/d7f3f901f1
Diffstat (limited to 'lib/rubygems/path_support.rb')
-rw-r--r-- | lib/rubygems/path_support.rb | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/rubygems/path_support.rb b/lib/rubygems/path_support.rb index 310d6a0669..b7900f67eb 100644 --- a/lib/rubygems/path_support.rb +++ b/lib/rubygems/path_support.rb @@ -24,13 +24,7 @@ class Gem::PathSupport # hashtable, or defaults to ENV, the system environment. # def initialize(env) - @home = env["GEM_HOME"] || Gem.default_dir - - if File::ALT_SEPARATOR - @home = @home.gsub(File::ALT_SEPARATOR, File::SEPARATOR) - end - - @home = expand(@home) + @home = default_home_dir(env) # If @home (aka Gem.paths.home) exists, but we can't write to it, # fall back to Gem.user_dir (the directory used for user installs). @@ -55,6 +49,20 @@ class Gem::PathSupport private ## + # The default home directory. + # This function was broken out to accommodate tests in `bundler/spec/commands/doctor_spec.rb`. + + def default_home_dir(env) + home = env["GEM_HOME"] || Gem.default_dir + + if File::ALT_SEPARATOR + home = home.gsub(File::ALT_SEPARATOR, File::SEPARATOR) + end + + expand(home) + end + + ## # Split the Gem search path (as reported by Gem.path). def split_gem_path(gpaths, home) |