From 618700a95cce54a2326811e39fb1311e4117c86c Mon Sep 17 00:00:00 2001 From: Ilya Kulakov Date: Fri, 13 Jan 2023 18:10:21 -0800 Subject: [PATCH] cask: don't assume that sudo has write access to the caskroom --- Library/Homebrew/cask/artifact/moved.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cask/artifact/moved.rb b/Library/Homebrew/cask/artifact/moved.rb index 53d09bed19..5e64409e33 100644 --- a/Library/Homebrew/cask/artifact/moved.rb +++ b/Library/Homebrew/cask/artifact/moved.rb @@ -79,7 +79,10 @@ module Cask if target.dirname.writable? FileUtils.move(source, target) else - command.run!("/bin/mv", args: [source, target], sudo: true) + # default sudo user isn't necessarily able to write to Homebrew's locations + # e.g. with runas_default set in the sudoers (5) file. + command.run!("/bin/cp", args: ["-pR", source, target], sudo: true) + source.rmtree end post_move(command)