From f5459acd79c30dbea3062e48fb2b12d510c5b868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Thu, 11 Jun 2020 17:30:45 +0200 Subject: [PATCH] Make sure tmp folder exists before calling `Dir.tmpdir` This was guaranteed by our gitignore setup where a `tmp/` folder is always present right after cloning the repository, but was not guaranteed under the ruby-core setup. This alternative approach should always work. --- lib/rubygems/test_case.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb index 76c783da37..bb8355ff9d 100644 --- a/lib/rubygems/test_case.rb +++ b/lib/rubygems/test_case.rb @@ -298,11 +298,14 @@ class Gem::TestCase < Minitest::Test super @orig_env = ENV.to_hash + @tmp = File.expand_path("tmp") + + Dir.mkdir @tmp ENV['GEM_VENDOR'] = nil ENV['GEMRC'] = nil ENV['SOURCE_DATE_EPOCH'] = nil - ENV["TMPDIR"] = File.expand_path("tmp") + ENV["TMPDIR"] = @tmp @current_dir = Dir.pwd @fetcher = nil @@ -319,7 +322,7 @@ class Gem::TestCase < Minitest::Test @tempdir = File.join(tmpdir, "test_rubygems_#{$$}") @tempdir.tap(&Gem::UNTAINT) - FileUtils.mkdir_p @tempdir + FileUtils.mkdir @tempdir @orig_SYSTEM_WIDE_CONFIG_FILE = Gem::ConfigFile::SYSTEM_WIDE_CONFIG_FILE Gem::ConfigFile.send :remove_const, :SYSTEM_WIDE_CONFIG_FILE @@ -445,7 +448,7 @@ class Gem::TestCase < Minitest::Test Dir.chdir @current_dir - FileUtils.rm_rf @tempdir + FileUtils.rm_rf @tmp ENV.replace(@orig_env)