diff --git a/Library/Homebrew/install.rb b/Library/Homebrew/install.rb index 215845e362..1d07053e03 100644 --- a/Library/Homebrew/install.rb +++ b/Library/Homebrew/install.rb @@ -24,6 +24,12 @@ module Homebrew Keg::MUST_EXIST_DIRECTORIES.each do |dir| begin FileUtils.mkdir_p(dir) unless dir.exist? + + # Create these files to ensure that these directories aren't removed + # by the Catalina installer. + # (https://github.com/Homebrew/brew/issues/6263) + keep_file = dir/".keepme" + FileUtils.touch(keep_file) unless keep_file.exist? rescue nil end