summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <gamblin2@llnl.gov>2021-10-28 14:33:44 -0700
committerGitHub <noreply@github.com>2021-10-28 21:33:44 +0000
commita1216138f6af6985e231fc8d7b2cf6011bb11a00 (patch)
treeb4b5939fbf19cc3933744d223e72a6d5f8541d44
parentd0e177e7118ebf1b55004e9ae34516af1266ad9a (diff)
downloadspack-a1216138f6af6985e231fc8d7b2cf6011bb11a00.tar.gz
spack-a1216138f6af6985e231fc8d7b2cf6011bb11a00.tar.bz2
spack-a1216138f6af6985e231fc8d7b2cf6011bb11a00.tar.xz
spack-a1216138f6af6985e231fc8d7b2cf6011bb11a00.zip
config: fix `SPACK_DISABLE_LOCAL_CONFIG`, remove `$user_config_path` (#27022)
There were some loose ends left in ##26735 that cause errors when using `SPACK_DISABLE_LOCAL_CONFIG`. - [x] Fix hard-coded `~/.spack` references in `install_test.py` and `monitor.py` Also, if `SPACK_DISABLE_LOCAL_CONFIG` is used, there is the issue that `$user_config_path`, when used in configuration files, makes no sense, because there is no user config scope. Since we already have `$user_cache_path` in configuration files, and since there really shouldn't be *any* data stored in a configuration scope (which is what you'd configure in `config.yaml`/`bootstrap.yaml`/etc., this just removes `$user_config_path`. There will *always* be a `$user_cache_path`, as Spack needs to write files, but we shouldn't rely on the existence of a particular configuration scope in the Spack code, as scopes are configurable, both in number and location. - [x] Remove `$user_config_path` substitution. - [x] Fix reference to `$user_config_path` in `etc/spack/deaults/bootstrap.yaml` to refer to `$user_cache_path`, which is where it was intended to be.
-rw-r--r--etc/spack/defaults/bootstrap.yaml4
-rw-r--r--lib/spack/docs/configuration.rst8
-rw-r--r--lib/spack/spack/install_test.py4
-rw-r--r--lib/spack/spack/monitor.py4
-rw-r--r--lib/spack/spack/paths.py5
-rw-r--r--lib/spack/spack/test/config.py7
-rw-r--r--lib/spack/spack/util/path.py2
7 files changed, 15 insertions, 19 deletions
diff --git a/etc/spack/defaults/bootstrap.yaml b/etc/spack/defaults/bootstrap.yaml
index 7a72bdfe6a..e51e406dff 100644
--- a/etc/spack/defaults/bootstrap.yaml
+++ b/etc/spack/defaults/bootstrap.yaml
@@ -4,7 +4,7 @@ bootstrap:
enable: true
# Root directory for bootstrapping work. The software bootstrapped
# by Spack is installed in a "store" subfolder of this root directory
- root: $user_config_path/bootstrap
+ root: $user_cache_path/bootstrap
# Methods that can be used to bootstrap software. Each method may or
# may not be able to bootstrap all of the software that Spack needs,
# depending on its type.
@@ -29,4 +29,4 @@ bootstrap:
# By default we trust bootstrapping from sources and from binaries
# produced on Github via the workflow
github-actions: true
- spack-install: true \ No newline at end of file
+ spack-install: true
diff --git a/lib/spack/docs/configuration.rst b/lib/spack/docs/configuration.rst
index 5d41f86997..57a1eaeb11 100644
--- a/lib/spack/docs/configuration.rst
+++ b/lib/spack/docs/configuration.rst
@@ -409,8 +409,6 @@ Spack understands several special variables. These are:
<https://docs.python.org/2/library/tempfile.html#tempfile.tempdir>`_
variable.
* ``$user``: name of the current user
-* ``$user_config_path``: user configuration directory (``~/.spack`` unless
- :ref:`overridden <local-config-overrides>`)
* ``$user_cache_path``: user cache directory (``~/.spack`` unless
:ref:`overridden <local-config-overrides>`)
@@ -587,9 +585,9 @@ Spack provides three environment variables that allow you to override or opt out
configuration locations:
* ``SPACK_USER_CONFIG_PATH``: Override the path to use for the
- ``user`` (``~/.spack``) scope.
-* ``SPACK_SYSTEM_CONFIG_PATH``: Override the path to use for the ``system``
- (``/etc/spack``) scope.
+ ``user`` scope (``~/.spack`` by default).
+* ``SPACK_SYSTEM_CONFIG_PATH``: Override the path to use for the
+ ``system`` scope (``/etc/spack`` by default).
* ``SPACK_DISABLE_LOCAL_CONFIG``: set this environment variable to completely disable
**both** the system and user configuration directories. Spack will only consider its
own defaults and ``site`` configuration locations.
diff --git a/lib/spack/spack/install_test.py b/lib/spack/spack/install_test.py
index 53fd07d7bb..07644f5cc5 100644
--- a/lib/spack/spack/install_test.py
+++ b/lib/spack/spack/install_test.py
@@ -13,6 +13,7 @@ import llnl.util.filesystem as fs
import llnl.util.tty as tty
import spack.error
+import spack.paths
import spack.util.prefix
import spack.util.spack_json as sjson
from spack.spec import Spec
@@ -41,7 +42,8 @@ def get_escaped_text_output(filename):
def get_test_stage_dir():
return spack.util.path.canonicalize_path(
- spack.config.get('config:test_stage', '~/.spack/test'))
+ spack.config.get('config:test_stage', spack.paths.default_test_path)
+ )
def get_all_test_suites():
diff --git a/lib/spack/spack/monitor.py b/lib/spack/spack/monitor.py
index d3a66c6d9b..c0df4ea680 100644
--- a/lib/spack/spack/monitor.py
+++ b/lib/spack/spack/monitor.py
@@ -28,6 +28,7 @@ import spack
import spack.config
import spack.hash_types as ht
import spack.main
+import spack.paths
import spack.store
import spack.util.path
import spack.util.spack_json as sjson
@@ -143,7 +144,8 @@ class SpackMonitorClient:
return
save_dir = spack.util.path.canonicalize_path(
- spack.config.get('config:monitor_dir', '~/.spack/reports/monitor'))
+ spack.config.get('config:monitor_dir', spack.paths.default_monitor_path)
+ )
# Name based on timestamp
now = datetime.now().strftime('%Y-%m-%d-%H-%M-%S-%s')
diff --git a/lib/spack/spack/paths.py b/lib/spack/spack/paths.py
index 70d138a932..6b3543406b 100644
--- a/lib/spack/spack/paths.py
+++ b/lib/spack/spack/paths.py
@@ -89,8 +89,11 @@ user_cache_path = _get_user_cache_path()
#: junit, cdash, etc. reports about builds
reports_path = os.path.join(user_cache_path, "reports")
+#: installation test (spack test) output
+default_test_path = os.path.join(user_cache_path, "test")
+
#: spack monitor analysis directories
-monitor_path = os.path.join(reports_path, "monitor")
+default_monitor_path = os.path.join(reports_path, "monitor")
#: git repositories fetched to compare commits to versions
user_repos_cache_path = os.path.join(user_cache_path, 'git_repos')
diff --git a/lib/spack/spack/test/config.py b/lib/spack/spack/test/config.py
index f2f8626b4f..fd6af8640b 100644
--- a/lib/spack/spack/test/config.py
+++ b/lib/spack/spack/test/config.py
@@ -432,13 +432,6 @@ def test_substitute_user(mock_low_high_config):
)
-def test_substitute_user_config(mock_low_high_config):
- user_config_path = spack.paths.user_config_path
- assert user_config_path + '/baz' == spack_path.canonicalize_path(
- '$user_cache_path/baz'
- )
-
-
def test_substitute_user_cache(mock_low_high_config):
user_cache_path = spack.paths.user_cache_path
assert user_cache_path + '/baz' == spack_path.canonicalize_path(
diff --git a/lib/spack/spack/util/path.py b/lib/spack/spack/util/path.py
index 8f76db93bb..19f35a9449 100644
--- a/lib/spack/spack/util/path.py
+++ b/lib/spack/spack/util/path.py
@@ -30,7 +30,6 @@ replacements = {
'spack': spack.paths.prefix,
'user': getpass.getuser(),
'tempdir': tempfile.gettempdir(),
- 'user_config_path': spack.paths.user_config_path,
'user_cache_path': spack.paths.user_cache_path,
}
@@ -80,7 +79,6 @@ def substitute_config_variables(path):
- $spack The Spack instance's prefix
- $tempdir Default temporary directory returned by tempfile.gettempdir()
- $user The current user's username
- - $user_config_path The user configuration directory (~/.spack, unless overridden)
- $user_cache_path The user cache directory (~/.spack, unless overridden)
These are substituted case-insensitively into the path, and users can