formulary: tighter path rejection detection.

We need to handle symlinks in both directions for formulae in the
cellar/taps/cache otherwise we can get the nonsensical situation of
telling people a formula must me in a tap when it already is (but is
symlinked from elsewhere).
This commit is contained in:
Mike McQuaid 2025-08-15 08:18:59 +01:00
parent 511cb44c71
commit 6024ccf7dd
No known key found for this signature in database

View File

@ -619,7 +619,8 @@ module Formulary
if Homebrew::EnvConfig.forbid_packages_from_paths?
path_realpath = path.realpath.to_s
path_string = path.to_s
unless path_realpath.start_with?("#{HOMEBREW_CELLAR}/", "#{HOMEBREW_LIBRARY}/Taps/", "#{HOMEBREW_CACHE}/")
if !path_realpath.start_with?("#{HOMEBREW_CELLAR}/", "#{HOMEBREW_LIBRARY}/Taps/", "#{HOMEBREW_CACHE}/") &&
!path_string.start_with?("#{HOMEBREW_CELLAR}/", "#{HOMEBREW_LIBRARY}/Taps/", "#{HOMEBREW_CACHE}/")
if path_string.include?("./") || path_string.end_with?(".rb") || path_string.count("/") != 2
raise <<~WARNING
Rejecting formula at #{path_string} because it's not in a tap.