From 33bd95625756562f4865fbc6ad5c39e0cfbc26d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Fri, 1 Dec 2023 12:53:43 +0100 Subject: [rubygems/rubygems] Better approach to falling back to user installation when GEM_HOME not writable https://github.com/rubygems/rubygems/commit/f67bced16b --- lib/rubygems/path_support.rb | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) (limited to 'lib/rubygems/path_support.rb') 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 @@ -18,32 +18,13 @@ class Gem::PathSupport # Directory with spec cache 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 -- cgit v1.2.3