diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 1f27b455ef..be9fd12085 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -104,6 +104,10 @@ HOMEBREW_CASKROOM="${HOMEBREW_PREFIX}/Caskroom" HOMEBREW_CACHE="${HOMEBREW_CACHE:-${HOMEBREW_DEFAULT_CACHE}}" HOMEBREW_LOGS="${HOMEBREW_LOGS:-${HOMEBREW_DEFAULT_LOGS}}" HOMEBREW_TEMP="${HOMEBREW_TEMP:-${HOMEBREW_DEFAULT_TEMP}}" +if [[ ! -w "${HOMEBREW_TEMP}" ]] +then + HOMEBREW_TEMP="${HOMEBREW_DEFAULT_TEMP}" +fi # commands that take a single or no arguments. # HOMEBREW_LIBRARY set by bin/brew diff --git a/Library/Homebrew/bundle/commands/exec.rb b/Library/Homebrew/bundle/commands/exec.rb index b0c00a7a47..e84764383c 100644 --- a/Library/Homebrew/bundle/commands/exec.rb +++ b/Library/Homebrew/bundle/commands/exec.rb @@ -111,6 +111,14 @@ module Homebrew # For commands which aren't either absolute or relative raise "command was not found in your PATH: #{command}" if command.exclude?("/") && which(command).nil? + %w[HOMEBREW_TEMP TMPDIR HOMEBREW_TMPDIR].each do |var| + value = ENV.fetch(var, nil) + next if value.blank? + next if File.writable?(value) + + ENV.delete(var) + end + if subcommand == "env" ENV.sort.each do |key, value| # No need to export empty values.