Fix bug that caused packages installed upstream to install module files to user directory

This commit is contained in:
Carson Woods
2020-07-15 13:40:27 -04:00
parent 4bb26802ed
commit dce7be9932
2 changed files with 14 additions and 2 deletions

View File

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

View File

@@ -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")