diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index f0fc5d6c6030d..b3712bd6a744c 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -343,13 +343,14 @@ def full_installed_alias_name # The path that was specified to find this formula. def specified_path - default_specified_path = Pathname(T.must(alias_path)) if alias_path.present? - default_specified_path ||= @unresolved_path + alias_pathname = Pathname(T.must(alias_path)) if alias_path.present? + return alias_pathname if alias_pathname&.exist? + + return @unresolved_path if @unresolved_path.exist? - return default_specified_path if default_specified_path.presence&.exist? return local_bottle_path if local_bottle_path.presence&.exist? - default_specified_path + alias_pathname || @unresolved_path end # The name specified to find this formula.