bin/brew: preserve XDG_CONFIG_HOME through environment filter#21648
Merged
MikeMcQuaid merged 1 commit intoHomebrew:mainfrom Mar 1, 2026
Merged
bin/brew: preserve XDG_CONFIG_HOME through environment filter#21648MikeMcQuaid merged 1 commit intoHomebrew:mainfrom
XDG_CONFIG_HOME through environment filter#21648MikeMcQuaid merged 1 commit intoHomebrew:mainfrom
Conversation
Add `XDG_CONFIG_HOME` to `USED_BY_HOMEBREW_VARS` so it is copied to `HOMEBREW_XDG_CONFIG_HOME` and survives the `env -i` filter, matching the existing pattern for `XDG_CACHE_HOME`, `XDG_DATA_DIRS` and `XDG_RUNTIME_DIR`. Also fall back to `HOMEBREW_XDG_CONFIG_HOME` when computing `HOMEBREW_USER_CONFIG_HOME`, so that the value is correct when `bin/brew` is re-executed after auto-update (via `exec` in `brew.sh`) and the original `XDG_CONFIG_HOME` has been filtered out. Without this fix, `brew bundle --global` fails with "No Brewfile found" for users whose Brewfile is at `$XDG_CONFIG_HOME/homebrew/Brewfile` whenever auto-update triggers a re-exec. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This comment was marked as spam.
This comment was marked as spam.
Contributor
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
bin/brewis a Bash script with no existing test coverage for the environment filtering logic.brew lgtm(style, typechecking and tests) with your changes locally?Claude Code (Claude Opus 4.6) was used to assist throughout the investigation and fix.
Manual verification:
XDG_CONFIG_HOMEis set, and$XDG_CONFIG_HOME/homebrew/Brewfileexistsbrew bundle --global installno longer fails with "No Brewfile found" when auto-update triggers a re-execSummary
XDG_CONFIG_HOMEtoUSED_BY_HOMEBREW_VARSso it is copied toHOMEBREW_XDG_CONFIG_HOMEand survives theenv -ifilter, matching the existing pattern forXDG_CACHE_HOME,XDG_DATA_DIRSandXDG_RUNTIME_DIRHOMEBREW_XDG_CONFIG_HOMEwhen computingHOMEBREW_USER_CONFIG_HOME, so that the value is correct whenbin/brewis re-executed after auto-updateProblem
brew bundle --globalfails with "No Brewfile found" for users whose Brewfile is at$XDG_CONFIG_HOME/homebrew/Brewfilewhenever auto-update triggers a re-exec viaexec "${HOMEBREW_BREW_FILE}" "$@"inbrew.sh.The
env -ienvironment filter inbin/brewstripsXDG_CONFIG_HOME. On the initial run this is not a problem becauseHOMEBREW_USER_CONFIG_HOMEis computed before the filter. However, after auto-update the re-exec goes throughbin/brewagain, whereHOMEBREW_USER_CONFIG_HOME(aBIN_BREW_EXPORTED_VARSmember) is recomputed — this time withoutXDG_CONFIG_HOME, causing it to fall back to~/.homebrew.This is the same class of issue that was fixed for
XDG_CACHE_HOMEin e1dda87.