Merge pull request #14370 from Kentzo/fix-cask-lowpriv-sudo

cask: don't assume that sudo has write access to the caskroom
This commit is contained in:
Mike McQuaid 2023-01-20 10:57:35 +00:00 committed by GitHub
commit 1adc2c096b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -82,7 +82,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)