catch exceptions in which_string (#40935)

This commit is contained in:
Harmen Stoppels 2023-11-07 17:17:31 +01:00 committed by GitHub
parent f3ba20db26
commit 75dfad8788
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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])