What happened
Since c9bfdc3 ("Extend sandboxing to package processing"), upgrading a formula whose url is a private GitHub repository (url "https://github.com/<owner>/<private-repo>.git", tag:, revision:) fails when the new tag has to be fetched:
fatal: could not read Username for 'https://github.com': terminal prompts disabled
git is configured with the GitHub CLI as its credential helper (credential.https://github.com.helper=!/opt/homebrew/bin/gh auth git-credential, as written by gh auth setup-git), and gh auth status reports the token is stored in the (keyring), which is the default on macOS.
Why
GitDownloadStrategy#allow_fetch_credentials recognises the gh auth git-credential helper and opens GH_CONFIG_DIR / ~/.config/gh to the sandbox. That is not enough when gh keeps its token in the macOS Keychain: the sandbox's home deny list in sandbox.rb still includes Library/Keychains, so gh auth git-credential get returns nothing and git falls back to a prompt it cannot show.
Reproduced outside brew with a profile containing only (deny file-read* (subpath "<home>/Library/Keychains")): under sandbox-exec, gh auth git-credential get returns no credential; without the profile it returns one.
Workaround
brew skips the fetch when the tag is already in the cached clone, so fetching it from a normal shell first lets the upgrade through:
git -C "$(brew --cache)/<name>--git" fetch origin tag <tag>
A first install (no cached clone yet) has no such workaround.
Environment
- Homebrew 7.0.6-21-g3f12c3e (on
main because homebrew.devcmdrun is set; 7.0.6 itself is not affected)
- macOS 27.0, Apple Silicon
- gh with the token in the keyring, git credential helper set by
gh auth setup-git
- Seen on two Macs
Suggestion
When the gh helper is detected and gh stores its token in the keyring, allow the sandboxed git process to reach the Keychain (read access to the login keychain, plus whatever mach lookup securityd needs). Or document that the helper is only supported with gh auth login --insecure-storage.
What happened
Since c9bfdc3 ("Extend sandboxing to package processing"), upgrading a formula whose
urlis a private GitHub repository (url "https://github.com/<owner>/<private-repo>.git", tag:, revision:) fails when the new tag has to be fetched:git is configured with the GitHub CLI as its credential helper (
credential.https://github.com.helper=!/opt/homebrew/bin/gh auth git-credential, as written bygh auth setup-git), andgh auth statusreports the token is stored in the(keyring), which is the default on macOS.Why
GitDownloadStrategy#allow_fetch_credentialsrecognises thegh auth git-credentialhelper and opensGH_CONFIG_DIR/~/.config/ghto the sandbox. That is not enough whenghkeeps its token in the macOS Keychain: the sandbox's home deny list insandbox.rbstill includesLibrary/Keychains, sogh auth git-credential getreturns nothing and git falls back to a prompt it cannot show.Reproduced outside brew with a profile containing only
(deny file-read* (subpath "<home>/Library/Keychains")): undersandbox-exec,gh auth git-credential getreturns no credential; without the profile it returns one.Workaround
brew skips the fetch when the tag is already in the cached clone, so fetching it from a normal shell first lets the upgrade through:
A first install (no cached clone yet) has no such workaround.
Environment
mainbecausehomebrew.devcmdrunis set; 7.0.6 itself is not affected)gh auth setup-gitSuggestion
When the
ghhelper is detected andghstores its token in the keyring, allow the sandboxed git process to reach the Keychain (read access to the login keychain, plus whatever mach lookupsecuritydneeds). Or document that the helper is only supported withgh auth login --insecure-storage.