From 75dfad8788f518e740a7e2fb80aabc1db61dd403 Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Tue, 7 Nov 2023 17:17:31 +0100 Subject: catch exceptions in which_string (#40935) --- lib/spack/spack/util/executable.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/util/executable.py b/lib/spack/spack/util/executable.py index 3aea141d87..36c7e73e06 100644 --- a/lib/spack/spack/util/executable.py +++ b/lib/spack/spack/util/executable.py @@ -330,8 +330,11 @@ def which_string(*args, **kwargs): 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]) -- cgit v1.2.3-60-g2f50