From dce7be9932851529103150fb9e84b43f814f5242 Mon Sep 17 00:00:00 2001 From: Carson Woods Date: Wed, 15 Jul 2020 13:40:27 -0400 Subject: [PATCH] Fix bug that caused packages installed upstream to install module files to user directory --- lib/spack/spack/modules/common.py | 15 +++++++++++++-- lib/spack/spack/paths.py | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/spack/spack/modules/common.py b/lib/spack/spack/modules/common.py index f57493a63e8..2928e364c5f 100644 --- a/lib/spack/spack/modules/common.py +++ b/lib/spack/spack/modules/common.py @@ -217,8 +217,19 @@ def root_path(name): """ # Root folders where the various module files should be written - roots = spack.config.get('config:module_roots', {}) - path = roots.get(name, os.path.join(spack.paths.share_path, name)) + active_upstream = spack.config.get('config:active_upstream') + if active_upstream is 'global': + # Installs module files to global upstream share directory + path = os.path.join(spack.paths.share_path, name) + elif active_upstream is not None: + # Installs module files to upstream share directory. + # Extra logic is needed for determining this location. + roots = spack.config.get('upstreams')[active_upstream][modules] + path = roots.get(name, os.path.join(spack.paths.user_share_path, name)) + else: + # If no upstream is active, install module files to user share directory. + roots = spack.config.get('config:module_roots', {}) + path = roots.get(name, os.path.join(spack.paths.user_share_path, name)) return spack.util.path.canonicalize_path(path) diff --git a/lib/spack/spack/paths.py b/lib/spack/spack/paths.py index 45d4747f453..2d59a7fa54e 100644 --- a/lib/spack/spack/paths.py +++ b/lib/spack/spack/paths.py @@ -45,6 +45,7 @@ stage_path = os.path.join(user_var_path, "stage") repos_path = os.path.join(var_path, "repos") share_path = os.path.join(prefix, "share", "spack") +user_share_path = os.path.join(user_config_path, "share", "spack") # Paths to built-in Spack repositories. packages_path = os.path.join(repos_path, "builtin")