From c6ddb9cedb56c4b291c394f6e988849f93b4c877 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 19 Aug 2024 09:17:21 +0100 Subject: [PATCH] brew.sh: hide ignorable permission errors. `GIT_DESCRIBE_CACHE` is a performance optimisation that doesn't clean up consistently when run with different Homebrew users. Instead of doing user detection: let's just hide these errors that we don't care about. Reported in: https://github.com/orgs/Homebrew/discussions/5479 --- Library/Homebrew/brew.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index c62896ba00..959d86149e 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -446,10 +446,13 @@ then then HOMEBREW_VERSION="$(cat "${GIT_DESCRIBE_CACHE_FILE}")" else - rm -rf "${GIT_DESCRIBE_CACHE}" HOMEBREW_VERSION="$("${HOMEBREW_GIT}" -C "${HOMEBREW_REPOSITORY}" describe --tags --dirty --abbrev=7 2>/dev/null)" - mkdir -p "${GIT_DESCRIBE_CACHE}" - echo "${HOMEBREW_VERSION}" >"${GIT_DESCRIBE_CACHE_FILE}" + # Don't output any permissions errors here. + # The user may not have write permissions to the cache but we don't care + # because it's an optional performance improvement. + rm -rf "${GIT_DESCRIBE_CACHE}" 2>/dev/null + mkdir -p "${GIT_DESCRIBE_CACHE}" 2>/dev/null + echo "${HOMEBREW_VERSION}" >"${GIT_DESCRIBE_CACHE_FILE}" 2>/dev/null fi unset GIT_DESCRIBE_CACHE_FILE else