From bb4208ebf1a67f0f5f6336b949ea2ae8b6670a61 Mon Sep 17 00:00:00 2001 From: notfirefox <138280734+notfirefox@users.noreply.github.com> Date: Sat, 14 Sep 2024 18:57:45 +0200 Subject: [PATCH] style: resolve symblic links in `HOMEBREW_CACHE` On Linux HOMEBREW_CACHE may be set to `$HOME/.cache/Homebrew`. Some systems, like Fedora Silverblue, have `/home` set up to be a symbolic link to `/var/home`. While Homebrew generally seems to work fine on Fedora Silverblue, rubocop causes the `brew style` command to emit a lot of warnings because of the symbolic link[1]. This can be resolved by looking up the real path of HOMEBREW_CACHE before passing it to rubocop. [1] https://github.com/rubocop/rubocop/issues/6228 Co-authored-by: Bo Anderson --- Library/Homebrew/style.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/style.rb b/Library/Homebrew/style.rb index a23e9b4398..6400f8f0af 100644 --- a/Library/Homebrew/style.rb +++ b/Library/Homebrew/style.rb @@ -164,7 +164,9 @@ module Homebrew args += files - cache_env = { "XDG_CACHE_HOME" => "#{HOMEBREW_CACHE}/style" } + HOMEBREW_CACHE.mkpath + cache_dir = HOMEBREW_CACHE.realpath + cache_env = { "XDG_CACHE_HOME" => "#{cache_dir}/style" } FileUtils.rm_rf cache_env["XDG_CACHE_HOME"] if reset_cache