summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorxndcn <xndchn@gmail.com>2020-08-04 13:25:59 +0800
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-09-28 14:54:22 +0900
commitac3f80a58e1d27b92e4f6d2f5a3cff8ba530e1e3 (patch)
tree48c55f9d2c1facf10f299bbd40025947f23f73ed /lib
parentc55b5f106295aa3c7611a15a9bf7f0d589447ea7 (diff)
[rubygems/rubygems] Add writable check for cache dir
Sometimes "install_dir/cache" directory is not writable although "install_dir" is writable. https://github.com/rubygems/rubygems/commit/665221cb69
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3599
Diffstat (limited to 'lib')
-rw-r--r--lib/rubygems/remote_fetcher.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb
index 20ddf471e1..40ac0e95c0 100644
--- a/lib/rubygems/remote_fetcher.rb
+++ b/lib/rubygems/remote_fetcher.rb
@@ -114,11 +114,12 @@ class Gem::RemoteFetcher
# always replaced.
def download(spec, source_uri, install_dir = Gem.dir)
+ install_cache_dir = File.join install_dir, "cache"
cache_dir =
if Dir.pwd == install_dir # see fetch_command
install_dir
- elsif File.writable? install_dir
- File.join install_dir, "cache"
+ elsif File.writable?(install_cache_dir) || (File.writable?(install_dir) && (not File.exist?(install_cache_dir)))
+ install_cache_dir
else
File.join Gem.user_dir, "cache"
end