diff --git a/Library/Homebrew/cli/named_args.rb b/Library/Homebrew/cli/named_args.rb index 98ab981c1852f..e4b9e115aae64 100644 --- a/Library/Homebrew/cli/named_args.rb +++ b/Library/Homebrew/cli/named_args.rb @@ -230,7 +230,7 @@ def to_paths(only: parent&.only_formula_or_cask, recurse_tap: false) @to_paths[only] ||= Homebrew.with_no_api_env_if_needed(@without_api) do downcased_unique_named.flat_map do |name| path = Pathname(name) - if File.exist?(name) + if only.nil? && File.exist?(name) path elsif name.count("/") == 1 && !name.start_with?("./", "/") tap = Tap.fetch(name)