Merge pull request #18927 from Homebrew/system-env-file-priority

bin/brew: fix prioritisation of system env files
This commit is contained in:
Carlo Cabrera 2024-12-13 06:37:05 +00:00 committed by GitHub
commit b670861ebb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -131,12 +131,12 @@ export_homebrew_env_file() {
} }
# First, load the system-wide configuration. # First, load the system-wide configuration.
export_homebrew_env_file "/etc/homebrew/brew.env"
unset SYSTEM_ENV_TAKES_PRIORITY unset SYSTEM_ENV_TAKES_PRIORITY
if [[ -n "${HOMEBREW_SYSTEM_ENV_TAKES_PRIORITY-}" ]] if [[ -n "${HOMEBREW_SYSTEM_ENV_TAKES_PRIORITY-}" ]]
then then
SYSTEM_ENV_TAKES_PRIORITY="1" SYSTEM_ENV_TAKES_PRIORITY="1"
else
export_homebrew_env_file "/etc/homebrew/brew.env"
fi fi
# Next, load the prefix configuration # Next, load the prefix configuration
@ -152,7 +152,7 @@ fi
export_homebrew_env_file "${HOMEBREW_USER_CONFIG_HOME}/brew.env" export_homebrew_env_file "${HOMEBREW_USER_CONFIG_HOME}/brew.env"
# If the system configuration takes priority, load it last. # If the system configuration takes priority, load it again to override any previous settings.
if [[ -n "${SYSTEM_ENV_TAKES_PRIORITY-}" ]] if [[ -n "${SYSTEM_ENV_TAKES_PRIORITY-}" ]]
then then
export_homebrew_env_file "/etc/homebrew/brew.env" export_homebrew_env_file "/etc/homebrew/brew.env"