diff options
author | David RodrÃguez <[email protected]> | 2023-12-01 12:53:43 +0100 |
---|---|---|
committer | Hiroshi SHIBATA <[email protected]> | 2023-12-07 13:56:22 +0900 |
commit | 33bd95625756562f4865fbc6ad5c39e0cfbc26d6 (patch) | |
tree | ab0a3ade84487022e7fd92b09e61fb9139d2f591 /lib/rubygems/path_support.rb | |
parent | 0f3f907e17bba1b94c5e202cb57988af8c6c91fc (diff) |
[rubygems/rubygems] Better approach to falling back to user installation when GEM_HOME not writable
https://github.com/rubygems/rubygems/commit/f67bced16b
Diffstat (limited to 'lib/rubygems/path_support.rb')
-rw-r--r-- | lib/rubygems/path_support.rb | 21 |
1 files changed, 1 insertions, 20 deletions
diff --git a/lib/rubygems/path_support.rb b/lib/rubygems/path_support.rb index 5d34120072..13091e29ba 100644 --- a/lib/rubygems/path_support.rb +++ b/lib/rubygems/path_support.rb @@ -19,31 +19,12 @@ class Gem::PathSupport attr_reader :spec_cache_dir # :nodoc: ## - # Whether `Gem.paths.home` defaulted to a user install or not. - attr_reader :auto_user_install - - ## # # Constructor. Takes a single argument which is to be treated like a # hashtable, or defaults to ENV, the system environment. # def initialize(env) - # Current implementation of @home, which is exposed as `Gem.paths.home`: - # 1. If `env["GEM_HOME"]` is defined in the environment: `env["GEM_HOME"]`. - # 2. If `Gem.default_dir` is writable: `Gem.default_dir`. - # 3. Otherwise: `Gem.user_dir`. - - if env.key?("GEM_HOME") - @home = normalize_home_dir(env["GEM_HOME"]) - elsif File.writable?(Gem.default_dir) - @home = normalize_home_dir(Gem.default_dir) - else - # If `GEM_HOME` is not set AND we can't use `Gem.default_dir`, - # default to a user installation and set `@auto_user_install`. - @auto_user_install = true - @home = normalize_home_dir(Gem.user_dir) - end - + @home = normalize_home_dir(env["GEM_HOME"] || Gem.default_dir) @path = split_gem_path env["GEM_PATH"], @home @spec_cache_dir = env["GEM_SPEC_CACHE"] || Gem.default_spec_cache_dir |