catch exceptions in which_string (#40935)

This commit is contained in:
Harmen Stoppels 2023-11-07 17:17:31 +01:00 committed by Harmen Stoppels
parent c232bf435a
commit 10ba172611

View file

@ -330,8 +330,11 @@ def add_extra_search_paths(paths):
for candidate_item in candidate_items:
for directory in search_paths:
exe = directory / candidate_item
if exe.is_file() and os.access(str(exe), os.X_OK):
return str(exe)
try:
if exe.is_file() and os.access(str(exe), os.X_OK):
return str(exe)
except OSError:
pass
if required:
raise CommandNotFoundError("spack requires '%s'. Make sure it is in your path." % args[0])