From ec800cccbb85bca59b405622017cb9b0b74c7cfe Mon Sep 17 00:00:00 2001 From: "John W. Parent" <45471568+johnwparent@users.noreply.github.com> Date: Wed, 10 May 2023 18:12:58 -0400 Subject: [PATCH] Windows: Fix external detection for service accounts (#37293) Prior to this PR, the HOMEDRIVE environment variable was used to detect what drive we are operating in. This variable is not available for service account logins (like what is used for CI), so switch to extracting the drive from PROGRAMFILES (which is more-widely defined). --- lib/spack/spack/detection/common.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/spack/spack/detection/common.py b/lib/spack/spack/detection/common.py index 8cb9d7d3acf..3e9856766fa 100644 --- a/lib/spack/spack/detection/common.py +++ b/lib/spack/spack/detection/common.py @@ -218,8 +218,10 @@ def update_configuration(detected_packages, scope=None, buildable=True): def _windows_drive(): - """Return Windows drive string""" - return os.environ["HOMEDRIVE"] + """Return Windows drive string extracted from PROGRAMFILES + env var, which is garunteed to be defined for all logins""" + drive = re.match(r"([a-zA-Z]:)", os.environ["PROGRAMFILES"]).group(1) + return drive class WindowsCompilerExternalPaths(object):