From 23cb93ff1c8f4536924c11d16669d2a51247fa50 Mon Sep 17 00:00:00 2001 From: Claudia Date: Fri, 3 Jul 2020 15:39:41 +0200 Subject: [PATCH] sandbox: do not assume home is inside `/Users` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s not uncommon to use `/var/${USER}` as a home directory, especially for shared or CLI-only users. This fixes an issue where a formula that requires `xcodebuild` is `brew install`ed from such a shared or CLI-only user account. In that case, `xcodebuild` would fail because it is denied writing to `/var/${USER}/Library/Developer/Xcode`. For details, see: https://gist.github.com/claui/17cd89f8f6b4094ac704f142ea811fd8 Suggested-by: Bo Anderson --- Library/Homebrew/sandbox.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/sandbox.rb b/Library/Homebrew/sandbox.rb index 6da3dc18c2..8e5d9bd384 100644 --- a/Library/Homebrew/sandbox.rb +++ b/Library/Homebrew/sandbox.rb @@ -47,12 +47,12 @@ class Sandbox end def allow_cvs - allow_write_path "/Users/#{ENV["USER"]}/.cvspass" + allow_write_path "#{ENV["HOME"]}/.cvspass" end def allow_fossil - allow_write_path "/Users/#{ENV["USER"]}/.fossil" - allow_write_path "/Users/#{ENV["USER"]}/.fossil-journal" + allow_write_path "#{ENV["HOME"]}/.fossil" + allow_write_path "#{ENV["HOME"]}/.fossil-journal" end def allow_write_cellar(formula) @@ -63,7 +63,7 @@ class Sandbox # Xcode projects expect access to certain cache/archive dirs. def allow_write_xcode - allow_write_path "/Users/#{ENV["USER"]}/Library/Developer" + allow_write_path "#{ENV["HOME"]}/Library/Developer" end def allow_write_log(formula)