Homebrew / brew

🍺 The missing package manager for macOS (or Linux)
https://brew.sh
BSD 2-Clause "Simplified" License
41.28k stars 9.7k forks source link

`brew install` call `gh attestation verify` Disrespect `XDG_CACHE_HOME` #18114

Closed EXHades closed 2 months ago

EXHades commented 2 months ago

brew doctor output

➜ brew doctor
Your system is ready to brew.

Verification

brew config output

HOMEBREW_VERSION: 4.3.17-72-g4362955
ORIGIN: https://github.com/Homebrew/brew.git
HEAD: 4362955bfcfceddde98b9ae12dc65a67aa25f42c
Last commit: 2 hours ago
Core tap JSON: 21 Aug 10:11 UTC
Core cask tap JSON: 21 Aug 10:13 UTC
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_EDITOR: nvim
HOMEBREW_MAKE_JOBS: 12
HOMEBREW_SORBET_RUNTIME: set
Homebrew Ruby: 3.3.4 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/3.3.4_1/bin/ruby
CPU: dodeca-core 64-bit kabylake
Clang: 15.0.0 build 1500
Git: 2.46.0 => /usr/local/bin/git
Curl: 8.7.1 => /usr/bin/curl
macOS: 14.6.1-x86_64
CLT: 15.3.0.0.1.1708646388
Xcode: 15.4

What were you trying to do (and why)?

I want to use XDG_CACHE_HOME change cache path , but brew install ignore XDG_CACHE_HOME, force create ~/.cache/gh/.sigstore/root

What happened (include all command output)?

➜ ls ~/.cache
total 0

# change cache path
➜ export XDG_CACHE_HOME="${HOME}/Library/Caches"

# install git-cliff for demo
➜ brew install -v -d --force-bottle git-cliff
...
==> Verifying attestation for git-cliff
/usr/bin/env GH_TOKEN=****** GH_HOST=github.com /usr/local/bin/gh attestation verify /Users/exhades/Library/Caches/Homebrew/downloads/7bf494d95b6ea269ed9a7aded75e5b755b22107e5da7318f095f3f87c5730655--git-cliff-2.4.0.sonoma.bottle.tar.gz --repo Homebrew/homebrew-core --format json
...

➜ ls ~/.cache
gh

➜ tree -a  ~/.cache/
~/.cache
└── gh
    └── .sigstore
        └── root
            ├── tuf-repo-cdn.sigstore.dev
            │   ├── root.json
            │   ├── snapshot.json
            │   ├── targets
            │   │   └── trusted_root.json
            │   ├── targets.json
            │   └── timestamp.json
            └── tuf-repo-cdn.sigstore.dev.json

What did you expect to happen?

gh cache save to XDG_CACHE_HOME="${HOME}/Library/Caches" path

Step-by-step reproduction instructions (by running brew commands)

As above
MikeMcQuaid commented 2 months ago

We don't support XDG_CACHE_HOME in Homebrew on macOS, sorry.

EXHades commented 2 months ago

gh supports XDG_CACHE_HOME by default on macOS, this issue it's just that brew seems to force override the XDG_CACHE_HOME environment variable when calling gh?

MikeMcQuaid commented 2 months ago

@EXHades Homebrew doesn't pass through XDG_CACHE_HOME to its environment on macOS.