aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/utils.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index a6c47b27a..1390db14e 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -244,7 +244,13 @@ end
def which(cmd, path = ENV["PATH"])
path.split(File::PATH_SEPARATOR).each do |p|
- pcmd = File.expand_path(cmd, p)
+ begin
+ pcmd = File.expand_path(cmd, p)
+ rescue ArgumentError
+ # File.expand_path will raise an ArgumentError if the path is malformed.
+ # See https://github.com/Homebrew/homebrew/issues/32789
+ next
+ end
return Pathname.new(pcmd) if File.file?(pcmd) && File.executable?(pcmd)
end
nil