Skip to content

Commit

Permalink
diagnostic: fix XDG_DATA_DIRS check
Browse files Browse the repository at this point in the history
1. Pass `XDG_DATA_DIRS` through so that it can be checked.
2. Promote the check to cross-platform status, as an incorrect `XDG_DATA_DIRS` also affects macOS formulae.
  • Loading branch information
gromgit committed Aug 3, 2024
1 parent ea9bb5b commit 5750789
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
13 changes: 13 additions & 0 deletions Library/Homebrew/diagnostic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,19 @@ def check_tmpdir_sticky_bit
end
alias generic_check_tmpdir_sticky_bit check_tmpdir_sticky_bit

def check_xdg_data_dirs
xdg_data_dirs = ENV.fetch("HOMEBREW_XDG_DATA_DIRS", nil)

Check warning on line 345 in Library/Homebrew/diagnostic.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/diagnostic.rb#L345

Added line #L345 was not covered by tests
return if xdg_data_dirs.blank? || xdg_data_dirs.split(":").include?(HOMEBREW_PREFIX/"share")

<<~EOS

Check warning on line 348 in Library/Homebrew/diagnostic.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/diagnostic.rb#L348

Added line #L348 was not covered by tests
Homebrew's share was not found in your XDG_DATA_DIRS but you have
this variable set to include other locations.
Some programs like `vapigen` may not work correctly.
Consider adding Homebrew's share directory to XDG_DATA_DIRS like so:
echo 'export XDG_DATA_DIRS="#{HOMEBREW_PREFIX}/share:$XDG_DATA_DIRS"' >> #{Utils::Shell.profile}
EOS
end

def check_exist_directories
return if HOMEBREW_PREFIX.writable?

Expand Down
13 changes: 0 additions & 13 deletions Library/Homebrew/extend/os/linux/diagnostic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,6 @@ def check_tmpdir_executable
f&.unlink
end

def check_xdg_data_dirs
xdg_data_dirs = ENV.fetch("XDG_DATA_DIRS", nil)
return if xdg_data_dirs.blank? || xdg_data_dirs.split("/").include?(HOMEBREW_PREFIX/"share")

<<~EOS
Homebrew's share was not found in your XDG_DATA_DIRS but you have
this variable set to include other locations.
Some programs like `vapigen` may not work correctly.
Consider adding Homebrew's share directory to XDG_DATA_DIRS like so:
echo 'export XDG_DATA_DIRS="#{HOMEBREW_PREFIX}/share:$XDG_DATA_DIRS"' >> #{Utils::Shell.profile}
EOS
end

def check_umask_not_zero
return unless File.umask.zero?

Expand Down
1 change: 1 addition & 0 deletions bin/brew
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ USED_BY_HOMEBREW_VARS=(
SUDO_USER
TMUX
XDG_CACHE_HOME
XDG_DATA_DIRS
XDG_RUNTIME_DIR
ZDOTDIR
)
Expand Down

0 comments on commit 5750789

Please sign in to comment.