diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 96ab6bf340..5512133cd0 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -1138,12 +1138,13 @@ class CoreTap < AbstractCoreTap def formula_files_by_name return super if Homebrew::EnvConfig.no_install_from_api? + tap_path = path.to_s Homebrew::API::Formula.all_formulae.each_with_object({}) do |item, hash| name, formula_hash = item # If there's more than one item with the same path: use the longer one to prioritise more specific results. existing_path = hash[name] - new_path = path/formula_hash["ruby_source_path"] - hash[name] = new_path if existing_path.nil? || existing_path.to_s.length < new_path.to_s.length + new_path = File.join(tap_path, formula_hash["ruby_source_path"]) # Pathname equivalent is slow in a tight loop + hash[name] = Pathname(new_path) if existing_path.nil? || existing_path.to_s.length < new_path.length end end end