Skip to content

Commit

Permalink
style: resolve symblic links in HOMEBREW_CACHE
Browse files Browse the repository at this point in the history
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] rubocop/rubocop#6228

Co-authored-by: Bo Anderson <[email protected]>
  • Loading branch information
notfirefox and Bo98 committed Sep 16, 2024
1 parent 1f306b4 commit bb4208e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Library/Homebrew/style.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ def self.run_rubocop(files, output_type,

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

Expand Down

0 comments on commit bb4208e

Please sign in to comment.