From 2090f057a0b72fc2718c01a3e824790c10c25f80 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 6 Feb 2019 21:18:06 +0100 Subject: [PATCH] Create parent directory for artifacts with `sudo` if necessary. --- Library/Homebrew/cask/artifact/moved.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cask/artifact/moved.rb b/Library/Homebrew/cask/artifact/moved.rb index eb97424f9a..e7d8d24847 100644 --- a/Library/Homebrew/cask/artifact/moved.rb +++ b/Library/Homebrew/cask/artifact/moved.rb @@ -40,7 +40,11 @@ module Cask end ohai "Moving #{self.class.english_name} '#{source.basename}' to '#{target}'." - target.dirname.mkpath + if target.dirname.parent.writable? + target.dirname.mkpath + else + command.run!("/bin/mkdir", args: ["-p", target.dirname], sudo: true) + end if target.parent.writable? FileUtils.move(source, target)