diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 629414bf71..f82edd031a 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -619,12 +619,13 @@ module Formulary if Homebrew::EnvConfig.forbid_packages_from_paths? path_realpath = path.realpath.to_s path_string = path.to_s - if !path_realpath.start_with?("#{HOMEBREW_CELLAR}/", "#{HOMEBREW_LIBRARY}/Taps/", "#{HOMEBREW_CACHE}/") && + if (path_realpath.end_with?(".rb") || path_string.end_with?(".rb")) && + !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. - Homebrew requires formulae to be in a tap. + Homebrew requires formulae to be in a tap, rejecting: + #{path_string} (#{path_realpath}) To create a tap, run e.g. brew tap-new / diff --git a/Library/Homebrew/test/formulary_spec.rb b/Library/Homebrew/test/formulary_spec.rb index d2be99e619..3ab0bafb71 100644 --- a/Library/Homebrew/test/formulary_spec.rb +++ b/Library/Homebrew/test/formulary_spec.rb @@ -126,7 +126,7 @@ RSpec.describe Formulary do described_class.factory(temp_formula_path) ensure temp_formula_path.unlink - end.to raise_error(RuntimeError, /Rejecting formula at/) + end.to raise_error(RuntimeError, /requires formulae to be in a tap, rejecting/) end it "returns a Formula when given a URL", :needs_utils_curl do