From 6024ccf7dd662681d4e1f9aa2e741603778e3be5 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Fri, 15 Aug 2025 08:18:59 +0100 Subject: [PATCH] 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). --- Library/Homebrew/formulary.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 92570e4e03..629414bf71 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -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.