Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logs ignore XDG_CACHE_HOME env variable while processing HOMEBREW_CACHE and HOMEBREW_LOGS #16156

Closed
4 tasks done
Tony-Sol opened this issue Oct 28, 2023 · 4 comments · Fixed by #16161
Closed
4 tasks done
Labels
bug Reproducible Homebrew/brew bug outdated PR was locked due to age

Comments

@Tony-Sol
Copy link

Tony-Sol commented Oct 28, 2023

brew gist-logs <formula> link OR brew config AND brew doctor output

$ brew config                                                                                        1 2023-10-28 04:46:38
HOMEBREW_VERSION: 4.1.17
ORIGIN: https://github.com/Homebrew/brew
HEAD: 35746e0a6ba6c3c5cfe56d99f79d9ec9f52ee15f
Last commit: 6 days ago
Core tap JSON: 28 Oct 01:43 UTC
HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew
HOMEBREW_CACHE: /home/tony/.local/cache/Homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_DISPLAY: :0
HOMEBREW_EDITOR: nvim
HOMEBREW_MAKE_JOBS: 20
Homebrew Ruby: 2.6.10 => /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.10_1/bin/ruby
CPU: 20-core 64-bit unknown_0x6_0x97
Clang: N/A
Git: 2.34.1 => /bin/git
Curl: 7.81.0 => /bin/curl
Kernel: Linux 5.15.123.1-microsoft-standard-WSL2 x86_64 GNU/Linux
OS: Ubuntu 22.04.3 LTS (jammy)
WSL: 2 (Microsoft Store)
Host glibc: 2.35
/usr/bin/gcc: 11.4.0
/usr/bin/ruby: N/A
glibc: N/A
gcc@11: N/A
gcc: 13.2.0
xorg: N/A

Verification

  • My "brew doctor output" says Your system is ready to brew. and am still able to reproduce my issue.
  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.
  • I searched for recent similar issues at https://github.com/Homebrew/homebrew-core/issues?q=is%3Aissue and found no duplicates.

What were you trying to do (and why)?

I was trying to set homebrew's cache into specific location via HOMEBREW_CACHE env, but it's still creates ~/.cache/Homebrew directory for logs which is not a suitable path in my case

What happened (include all command output)?

Screenshot 2023-10-28 050930

What did you expect to happen?

Logs will be created in ${HOMEBREW_CACHE}/Logsas man page says
Screenshot 2023-10-28 050727
Screenshot 2023-10-28 050818

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

rm -Rf ~/.cache/Homebrew # drop old cache dir
HOMEBREW_CACHE="${HOME}/.homebrew-cache" brew <anything> # do something
ls -la ~/ # see that there are two dirs - ~/.homebrew-cache AND again ~/.cache/Homebrew/Logs
@Tony-Sol Tony-Sol added the bug Reproducible Homebrew/brew bug label Oct 28, 2023
@SMillerDev
Copy link
Member

This should be filed in Homebrew/brew since it is about the behaviour of the brew tool, not about a package.

Additionally, please don't use images to report terminal output. It makes it much harder to scale and read than just text

@MikeMcQuaid MikeMcQuaid transferred this issue from Homebrew/homebrew-core Oct 28, 2023
@apainintheneck
Copy link
Contributor

The relevant code is here:

if [[ -n "${HOMEBREW_MACOS}" ]]
then
HOMEBREW_DEFAULT_CACHE="${HOME}/Library/Caches/Homebrew"
HOMEBREW_DEFAULT_LOGS="${HOME}/Library/Logs/Homebrew"
HOMEBREW_DEFAULT_TEMP="/private/tmp"
else
CACHE_HOME="${XDG_CACHE_HOME:-${HOME}/.cache}"
HOMEBREW_DEFAULT_CACHE="${CACHE_HOME}/Homebrew"
HOMEBREW_DEFAULT_LOGS="${CACHE_HOME}/Homebrew/Logs"
HOMEBREW_DEFAULT_TEMP="/tmp"
fi

HOMEBREW_CACHE="${HOMEBREW_CACHE:-${HOMEBREW_DEFAULT_CACHE}}"
HOMEBREW_LOGS="${HOMEBREW_LOGS:-${HOMEBREW_DEFAULT_LOGS}}"
HOMEBREW_TEMP="${HOMEBREW_TEMP:-${HOMEBREW_DEFAULT_TEMP}}"

Nothing looks obviously wrong though.

@Bo98
Copy link
Member

Bo98 commented Oct 28, 2023

Nothing looks obviously wrong though.

Probably an env filtering issue

@apainintheneck
Copy link
Contributor

Yeah, that's exactly it. I assume we don't allow this to pass through because it could affect build reproducibility.

We need to at least pass it from bin/brew to brew.sh where these values are set. The obvious thing to do here would be to just create a new HOMEBREW_XDG_CACHE_HOME variable that we export internally with the value of XDG_CACHE_HOME if it is set.

@github-actions github-actions bot added the outdated PR was locked due to age label Nov 29, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Reproducible Homebrew/brew bug outdated PR was locked due to age
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants