2022-01-13 03:21:41 +08:00
|
|
|
.. Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
|
2018-10-08 04:52:23 +08:00
|
|
|
Spack Project Developers. See the top-level COPYRIGHT file for details.
|
|
|
|
|
|
|
|
SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
|
|
|
|
2016-05-22 05:33:05 +08:00
|
|
|
.. _configuration:
|
2014-01-05 06:43:44 +08:00
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
===================
|
|
|
|
Configuration Files
|
|
|
|
===================
|
2016-10-29 07:17:58 +08:00
|
|
|
|
|
|
|
Spack has many configuration files. Here is a quick list of them, in
|
|
|
|
case you want to skip directly to specific docs:
|
|
|
|
|
|
|
|
* :ref:`compilers.yaml <compiler-config>`
|
2022-02-13 17:26:53 +08:00
|
|
|
* :ref:`concretizer.yaml <concretizer-options>`
|
2016-10-29 07:17:58 +08:00
|
|
|
* :ref:`config.yaml <config-yaml>`
|
|
|
|
* :ref:`mirrors.yaml <mirrors>`
|
|
|
|
* :ref:`modules.yaml <modules>`
|
|
|
|
* :ref:`packages.yaml <build-settings>`
|
2016-12-12 16:54:20 +08:00
|
|
|
* :ref:`repos.yaml <repositories>`
|
2016-10-29 07:17:58 +08:00
|
|
|
|
2022-02-13 17:26:53 +08:00
|
|
|
You can also add any of these as inline configuration in ``spack.yaml``
|
|
|
|
in an :ref:`environment <environment-configuration>`.
|
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
-----------
|
2016-10-29 07:17:58 +08:00
|
|
|
YAML Format
|
2018-11-12 02:57:46 +08:00
|
|
|
-----------
|
2016-10-29 07:17:58 +08:00
|
|
|
|
|
|
|
Spack configuration files are written in YAML. We chose YAML because
|
|
|
|
it's human readable, but also versatile in that it supports dictionaries,
|
|
|
|
lists, and nested sections. For more details on the format, see `yaml.org
|
|
|
|
<http://yaml.org>`_ and `libyaml <http://pyyaml.org/wiki/LibYAML>`_.
|
|
|
|
Here is an example ``config.yaml`` file:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
config:
|
|
|
|
install_tree: $spack/opt/spack
|
|
|
|
build_stage:
|
2019-09-04 07:31:27 +08:00
|
|
|
- $tempdir/$user/spack-stage
|
|
|
|
- ~/.spack/stage
|
2016-10-29 07:17:58 +08:00
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
Each Spack configuration file is nested under a top-level section
|
2016-10-29 07:17:58 +08:00
|
|
|
corresponding to its name. So, ``config.yaml`` starts with ``config:``,
|
2018-11-12 02:57:46 +08:00
|
|
|
``mirrors.yaml`` starts with ``mirrors:``, etc.
|
2016-10-29 07:17:58 +08:00
|
|
|
|
|
|
|
.. _configuration-scopes:
|
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
--------------------
|
2016-10-29 07:17:58 +08:00
|
|
|
Configuration Scopes
|
2018-11-12 02:57:46 +08:00
|
|
|
--------------------
|
2016-10-29 07:17:58 +08:00
|
|
|
|
|
|
|
Spack pulls configuration data from files in several directories. There
|
2018-11-12 02:57:46 +08:00
|
|
|
are six configuration scopes. From lowest to highest:
|
2016-10-29 07:17:58 +08:00
|
|
|
|
2017-06-17 03:31:56 +08:00
|
|
|
#. **defaults**: Stored in ``$(prefix)/etc/spack/defaults/``. These are
|
2016-10-29 07:17:58 +08:00
|
|
|
the "factory" settings. Users should generally not modify the settings
|
|
|
|
here, but should override them in other configuration scopes. The
|
|
|
|
defaults here will change from version to version of Spack.
|
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
#. **system**: Stored in ``/etc/spack/``. These are settings for this
|
2017-06-17 03:31:56 +08:00
|
|
|
machine, or for all machines on which this file system is
|
|
|
|
mounted. The site scope can be used for settings idiosyncratic to a
|
|
|
|
particular machine, such as the locations of compilers or external
|
|
|
|
packages. These settings are presumably controlled by someone with
|
2018-11-12 02:57:46 +08:00
|
|
|
root access on the machine. They override the defaults scope.
|
|
|
|
|
|
|
|
#. **site**: Stored in ``$(prefix)/etc/spack/``. Settings here affect
|
|
|
|
only *this instance* of Spack, and they override the defaults and system
|
|
|
|
scopes. The site scope can can be used for per-project settings (one
|
|
|
|
Spack instance per project) or for site-wide settings on a multi-user
|
|
|
|
machine (e.g., for a common Spack instance).
|
2017-06-17 03:31:56 +08:00
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
#. **user**: Stored in the home directory: ``~/.spack/``. These settings
|
|
|
|
affect all instances of Spack and take higher precedence than site,
|
|
|
|
system, or defaults scopes.
|
2016-10-29 07:17:58 +08:00
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
#. **custom**: Stored in a custom directory specified by ``--config-scope``.
|
|
|
|
If multiple scopes are listed on the command line, they are ordered
|
|
|
|
from lowest to highest precedence.
|
2016-12-30 10:13:55 +08:00
|
|
|
|
2021-03-21 18:14:13 +08:00
|
|
|
#. **environment**: When using Spack :ref:`environments`, Spack reads
|
|
|
|
additional configuration from the environment file. See
|
|
|
|
:ref:`environment-configuration` for further details on these
|
|
|
|
scopes. Environment scopes can be referenced from the command line
|
|
|
|
as ``env:name`` (to reference environment ``foo``, use
|
|
|
|
``env:foo``).
|
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
#. **command line**: Build settings specified on the command line take
|
|
|
|
precedence over all other scopes.
|
2016-10-29 07:17:58 +08:00
|
|
|
|
|
|
|
Each configuration directory may contain several configuration files,
|
|
|
|
such as ``config.yaml``, ``compilers.yaml``, or ``mirrors.yaml``. When
|
|
|
|
configurations conflict, settings from higher-precedence scopes override
|
|
|
|
lower-precedence settings.
|
|
|
|
|
|
|
|
Commands that modify scopes (e.g., ``spack compilers``, ``spack repo``,
|
|
|
|
etc.) take a ``--scope=<name>`` parameter that you can use to control
|
2018-11-12 02:57:46 +08:00
|
|
|
which scope is modified. By default, they modify the highest-precedence
|
2016-10-29 07:17:58 +08:00
|
|
|
scope.
|
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
.. _custom-scopes:
|
2016-12-30 10:13:55 +08:00
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
^^^^^^^^^^^^^
|
|
|
|
Custom scopes
|
|
|
|
^^^^^^^^^^^^^
|
2016-12-30 10:13:55 +08:00
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
In addition to the ``defaults``, ``system``, ``site``, and ``user``
|
|
|
|
scopes, you may add configuration scopes directly on the command
|
|
|
|
line with the ``--config-scope`` argument, or ``-C`` for short.
|
2016-12-30 10:13:55 +08:00
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
For example, the following adds two configuration scopes, named
|
|
|
|
``scopea`` and ``scopeb``, to a ``spack spec`` command:
|
2016-12-30 10:13:55 +08:00
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ spack -C ~/myscopes/scopea -C ~/myscopes/scopeb spec ncurses
|
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
Custom scopes come *after* the ``spack`` command and *before* the
|
2016-12-30 10:13:55 +08:00
|
|
|
subcommand, and they specify a single path to a directory full of
|
|
|
|
configuration files. You can add the same configuration files to that
|
2018-11-12 02:57:46 +08:00
|
|
|
directory that you can add to any other scope (``config.yaml``,
|
2016-12-30 10:13:55 +08:00
|
|
|
``packages.yaml``, etc.).
|
|
|
|
|
|
|
|
If multiple scopes are provided:
|
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
#. Each must be preceded with the ``--config-scope`` or ``-C`` flag.
|
|
|
|
#. They must be ordered from lowest to highest precedence.
|
2016-12-30 10:13:55 +08:00
|
|
|
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
Example: scopes for release and development
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
Suppose that you need to support simultaneous building of release and
|
|
|
|
development versions of ``mypackage``, where ``mypackage`` -> ``A`` -> ``B``.
|
2016-12-30 10:13:55 +08:00
|
|
|
You could create The following files:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
2018-11-12 02:57:46 +08:00
|
|
|
:caption: ~/myscopes/release/packages.yaml
|
2016-12-30 10:13:55 +08:00
|
|
|
|
|
|
|
packages:
|
|
|
|
mypackage:
|
|
|
|
version: [1.7]
|
|
|
|
A:
|
|
|
|
version: [2.3]
|
|
|
|
B:
|
|
|
|
version: [0.8]
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
2018-11-12 02:57:46 +08:00
|
|
|
:caption: ~/myscopes/develop/packages.yaml
|
2016-12-30 10:13:55 +08:00
|
|
|
|
|
|
|
packages:
|
|
|
|
mypackage:
|
|
|
|
version: [develop]
|
|
|
|
A:
|
|
|
|
version: [develop]
|
|
|
|
B:
|
|
|
|
version: [develop]
|
|
|
|
|
|
|
|
You can switch between ``release`` and ``develop`` configurations using
|
|
|
|
configuration arguments. You would type ``spack -C ~/myscopes/release``
|
|
|
|
when you want to build the designated release versions of ``mypackage``,
|
|
|
|
``A``, and ``B``, and you would type ``spack -C ~/myscopes/develop`` when
|
|
|
|
you want to build all of these packages at the ``develop`` version.
|
|
|
|
|
|
|
|
"""""""""""""""""""""""""""""""
|
|
|
|
Example: swapping MPI providers
|
|
|
|
"""""""""""""""""""""""""""""""
|
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
Suppose that you need to build two software packages, ``packagea`` and
|
|
|
|
``packageb``. ``packagea`` is Python 2-based and ``packageb`` is Python
|
|
|
|
3-based. ``packagea`` only builds with OpenMPI and ``packageb`` only builds
|
|
|
|
with MPICH. You can create different configuration scopes for use with
|
|
|
|
``packagea`` and ``packageb``:
|
2016-12-30 10:13:55 +08:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
2018-11-12 02:57:46 +08:00
|
|
|
:caption: ~/myscopes/packgea/packages.yaml
|
2016-12-30 10:13:55 +08:00
|
|
|
|
|
|
|
packages:
|
|
|
|
python:
|
|
|
|
version: [2.7.11]
|
|
|
|
all:
|
|
|
|
providers:
|
|
|
|
mpi: [openmpi]
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
2018-11-12 02:57:46 +08:00
|
|
|
:caption: ~/myscopes/packageb/packages.yaml
|
2016-12-30 10:13:55 +08:00
|
|
|
|
|
|
|
packages:
|
|
|
|
python:
|
|
|
|
version: [3.5.2]
|
|
|
|
all:
|
|
|
|
providers:
|
|
|
|
mpi: [mpich]
|
|
|
|
|
|
|
|
|
2016-10-29 07:17:58 +08:00
|
|
|
.. _platform-scopes:
|
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
------------------------
|
|
|
|
Platform-specific Scopes
|
|
|
|
------------------------
|
|
|
|
|
2021-03-21 18:14:13 +08:00
|
|
|
For each scope above (excluding environment scopes), there can also be
|
|
|
|
platform-specific settings. For example, on most platforms, GCC is
|
|
|
|
the preferred compiler. However, on macOS (darwin), Clang often works
|
|
|
|
for more packages, and is set as the default compiler. This
|
|
|
|
configuration is set in
|
2018-11-12 02:57:46 +08:00
|
|
|
``$(prefix)/etc/spack/defaults/darwin/packages.yaml``. It will take
|
|
|
|
precedence over settings in the ``defaults`` scope, but can still be
|
|
|
|
overridden by settings in ``system``, ``system/darwin``, ``site``,
|
|
|
|
``site/darwin``, ``user``, ``user/darwin``, ``custom``, or
|
|
|
|
``custom/darwin``. So, the full scope precedence is:
|
|
|
|
|
|
|
|
#. ``defaults``
|
|
|
|
#. ``defaults/<platform>``
|
|
|
|
#. ``system``
|
|
|
|
#. ``system/<platform>``
|
|
|
|
#. ``site``
|
|
|
|
#. ``site/<platform>``
|
|
|
|
#. ``user``
|
|
|
|
#. ``user/<platform>``
|
|
|
|
#. ``custom``
|
|
|
|
#. ``custom/<platform>``
|
2016-10-29 07:17:58 +08:00
|
|
|
|
|
|
|
You can get the name to use for ``<platform>`` by running ``spack arch
|
2017-06-17 03:31:56 +08:00
|
|
|
--platform``. The system config scope has a ``<platform>`` section for
|
|
|
|
sites at which ``/etc`` is mounted on multiple heterogeneous machines.
|
2016-10-29 07:17:58 +08:00
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
----------------
|
|
|
|
Scope Precedence
|
|
|
|
----------------
|
2016-10-29 07:17:58 +08:00
|
|
|
|
|
|
|
When spack queries for configuration parameters, it searches in
|
2018-11-12 02:57:46 +08:00
|
|
|
higher-precedence scopes first. So, settings in a higher-precedence file
|
|
|
|
can override those with the same key in a lower-precedence one. For
|
2016-10-29 07:17:58 +08:00
|
|
|
list-valued settings, Spack *prepends* higher-precedence settings to
|
|
|
|
lower-precedence settings. Completely ignoring higher-level configuration
|
|
|
|
options is supported with the ``::`` notation for keys (see
|
|
|
|
:ref:`config-overrides` below).
|
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
^^^^^^^^^^^
|
2016-10-29 07:17:58 +08:00
|
|
|
Simple keys
|
2018-11-12 02:57:46 +08:00
|
|
|
^^^^^^^^^^^
|
2016-10-29 07:17:58 +08:00
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
Let's look at an example of overriding a single key in a Spack file. If
|
2016-10-29 07:17:58 +08:00
|
|
|
your configurations look like this:
|
|
|
|
|
2015-10-06 05:04:33 +08:00
|
|
|
.. code-block:: yaml
|
2018-11-12 02:57:46 +08:00
|
|
|
:caption: $(prefix)/etc/spack/defaults/config.yaml
|
2015-10-06 05:04:33 +08:00
|
|
|
|
2016-10-29 07:17:58 +08:00
|
|
|
config:
|
|
|
|
install_tree: $spack/opt/spack
|
|
|
|
build_stage:
|
2019-09-04 07:31:27 +08:00
|
|
|
- $tempdir/$user/spack-stage
|
|
|
|
- ~/.spack/stage
|
2016-10-29 07:17:58 +08:00
|
|
|
|
2015-10-06 05:04:33 +08:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
2018-11-12 02:57:46 +08:00
|
|
|
:caption: ~/.spack/config.yaml
|
2015-10-06 05:04:33 +08:00
|
|
|
|
2016-10-29 07:17:58 +08:00
|
|
|
config:
|
|
|
|
install_tree: /some/other/directory
|
2015-10-06 05:04:33 +08:00
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
|
2016-10-29 07:17:58 +08:00
|
|
|
Spack will only override ``install_tree`` in the ``config`` section, and
|
2018-11-12 02:57:46 +08:00
|
|
|
will take the site preferences for other settings. You can see the
|
2016-10-29 07:17:58 +08:00
|
|
|
final, combined configuration with the ``spack config get <configtype>``
|
|
|
|
command:
|
2015-10-06 05:04:33 +08:00
|
|
|
|
2016-10-29 07:17:58 +08:00
|
|
|
.. code-block:: console
|
|
|
|
:emphasize-lines: 3
|
2016-06-28 04:52:48 +08:00
|
|
|
|
2016-10-29 07:17:58 +08:00
|
|
|
$ spack config get config
|
|
|
|
config:
|
|
|
|
install_tree: /some/other/directory
|
|
|
|
build_stage:
|
2019-09-04 07:31:27 +08:00
|
|
|
- $tempdir/$user/spack-stage
|
|
|
|
- ~/.spack/stage
|
2018-11-12 02:57:46 +08:00
|
|
|
|
2016-03-11 08:18:11 +08:00
|
|
|
|
2016-10-29 07:17:58 +08:00
|
|
|
.. _config-overrides:
|
2016-10-06 04:00:27 +08:00
|
|
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2016-10-29 07:17:58 +08:00
|
|
|
Overriding entire sections
|
2016-10-06 04:00:27 +08:00
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
Above, the user ``config.yaml`` only overrides specific settings in the
|
|
|
|
default ``config.yaml``. Sometimes, it is useful to *completely*
|
|
|
|
override lower-precedence settings. To do this, you can use *two* colons
|
|
|
|
at the end of a key in a configuration file. For example:
|
2016-10-29 07:17:58 +08:00
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
:emphasize-lines: 1
|
2018-11-12 02:57:46 +08:00
|
|
|
:caption: ~/.spack/config.yaml
|
2016-10-29 07:17:58 +08:00
|
|
|
|
|
|
|
config::
|
|
|
|
install_tree: /some/other/directory
|
2016-10-06 04:00:27 +08:00
|
|
|
|
2016-10-29 07:17:58 +08:00
|
|
|
Spack will ignore all lower-precedence configuration under the
|
|
|
|
``config::`` section:
|
2016-10-06 04:00:27 +08:00
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
2016-10-29 07:17:58 +08:00
|
|
|
$ spack config get config
|
|
|
|
config:
|
|
|
|
install_tree: /some/other/directory
|
2016-10-06 04:00:27 +08:00
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^
|
2016-10-29 07:17:58 +08:00
|
|
|
List-valued settings
|
2018-11-12 02:57:46 +08:00
|
|
|
^^^^^^^^^^^^^^^^^^^^
|
2016-10-06 04:00:27 +08:00
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
Let's revisit the ``config.yaml`` example one more time. The
|
2016-10-29 07:17:58 +08:00
|
|
|
``build_stage`` setting's value is an ordered list of directories:
|
2016-10-06 04:00:27 +08:00
|
|
|
|
2016-10-29 07:17:58 +08:00
|
|
|
.. code-block:: yaml
|
2018-11-12 02:57:46 +08:00
|
|
|
:caption: $(prefix)/etc/spack/defaults/config.yaml
|
2016-10-29 07:17:58 +08:00
|
|
|
|
|
|
|
build_stage:
|
2019-09-04 07:31:27 +08:00
|
|
|
- $tempdir/$user/spack-stage
|
|
|
|
- ~/.spack/stage
|
2016-05-22 05:33:05 +08:00
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
|
2016-10-29 07:17:58 +08:00
|
|
|
Suppose the user configuration adds its *own* list of ``build_stage``
|
|
|
|
paths:
|
2016-05-22 05:33:05 +08:00
|
|
|
|
2016-08-27 05:41:00 +08:00
|
|
|
.. code-block:: yaml
|
2018-11-12 02:57:46 +08:00
|
|
|
:caption: ~/.spack/config.yaml
|
2016-05-22 05:33:05 +08:00
|
|
|
|
2016-10-29 07:17:58 +08:00
|
|
|
build_stage:
|
2019-09-04 07:31:27 +08:00
|
|
|
- /lustre-scratch/$user/spack
|
2016-10-29 07:17:58 +08:00
|
|
|
- ~/mystage
|
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
|
|
|
|
Spack will first look at the paths in the defaults ``config.yaml``, then the
|
|
|
|
paths in the user's ``~/.spack/config.yaml``. The list in the
|
|
|
|
higher-precedence scope is *prepended* to the defaults. ``spack config
|
2016-10-29 07:17:58 +08:00
|
|
|
get config`` shows the result:
|
|
|
|
|
|
|
|
.. code-block:: console
|
2022-04-09 03:00:35 +08:00
|
|
|
:emphasize-lines: 5-8
|
2016-10-29 07:17:58 +08:00
|
|
|
|
|
|
|
$ spack config get config
|
|
|
|
config:
|
|
|
|
install_tree: /some/other/directory
|
|
|
|
build_stage:
|
2019-09-04 07:31:27 +08:00
|
|
|
- /lustre-scratch/$user/spack
|
2016-10-29 07:17:58 +08:00
|
|
|
- ~/mystage
|
2019-09-04 07:31:27 +08:00
|
|
|
- $tempdir/$user/spack-stage
|
|
|
|
- ~/.spack/stage
|
2018-11-12 02:57:46 +08:00
|
|
|
|
2016-10-29 07:17:58 +08:00
|
|
|
|
|
|
|
As in :ref:`config-overrides`, the higher-precedence scope can
|
2018-11-12 02:57:46 +08:00
|
|
|
*completely* override the lower-precedence scope using ``::``. So if the
|
2016-10-29 07:17:58 +08:00
|
|
|
user config looked like this:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
:emphasize-lines: 1
|
2018-11-12 02:57:46 +08:00
|
|
|
:caption: ~/.spack/config.yaml
|
2016-10-29 07:17:58 +08:00
|
|
|
|
|
|
|
build_stage::
|
2019-09-04 07:31:27 +08:00
|
|
|
- /lustre-scratch/$user/spack
|
2016-10-29 07:17:58 +08:00
|
|
|
- ~/mystage
|
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
|
2016-10-29 07:17:58 +08:00
|
|
|
The merged configuration would look like this:
|
|
|
|
|
|
|
|
.. code-block:: console
|
2022-04-09 03:00:35 +08:00
|
|
|
:emphasize-lines: 5-6
|
2016-10-29 07:17:58 +08:00
|
|
|
|
|
|
|
$ spack config get config
|
|
|
|
config:
|
|
|
|
install_tree: /some/other/directory
|
|
|
|
build_stage:
|
2019-09-04 07:31:27 +08:00
|
|
|
- /lustre-scratch/$user/spack
|
2016-10-29 07:17:58 +08:00
|
|
|
- ~/mystage
|
2018-11-12 02:57:46 +08:00
|
|
|
|
2017-08-22 09:35:00 +08:00
|
|
|
|
|
|
|
.. _config-file-variables:
|
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
---------------------
|
|
|
|
Config File Variables
|
|
|
|
---------------------
|
2017-08-22 09:35:00 +08:00
|
|
|
|
2018-06-24 15:48:02 +08:00
|
|
|
Spack understands several variables which can be used in config file
|
2018-11-12 02:57:46 +08:00
|
|
|
paths wherever they appear. There are three sets of these variables:
|
|
|
|
Spack-specific variables, environment variables, and user path
|
|
|
|
variables. Spack-specific variables and environment variables are both
|
2018-06-24 15:48:02 +08:00
|
|
|
indicated by prefixing the variable name with ``$``. User path variables
|
2018-11-12 02:57:46 +08:00
|
|
|
are indicated at the start of the path with ``~`` or ``~user``.
|
2017-08-22 09:35:00 +08:00
|
|
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^
|
2018-06-24 15:48:02 +08:00
|
|
|
Spack-specific variables
|
2017-08-22 09:35:00 +08:00
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
2022-12-03 02:27:37 +08:00
|
|
|
Spack understands over a dozen special variables. These are:
|
2017-08-22 09:35:00 +08:00
|
|
|
|
config: overrides for caches and system and user scopes (#26735)
Spack's `system` and `user` scopes provide ways for administrators and
users to set global defaults for all Spack instances, but for use cases
where one wants a clean Spack installation, these scopes can be undesirable.
For example, users may want to opt out of global system configuration, or
they may want to ignore their own home directory settings when running in
a continuous integration environment.
Spack also, by default, keeps various caches and user data in `~/.spack`,
but users may want to override these locations.
Spack provides three environment variables that allow you to override or
opt out of 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.
* `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.
And one that allows you to move the default cache location:
* `SPACK_USER_CACHE_PATH`: Override the default path to use for user data
(misc_cache, tests, reports, etc.)
With these settings, if you want to isolate Spack in a CI environment, you can do this:
export SPACK_DISABLE_LOCAL_CONFIG=true
export SPACK_USER_CACHE_PATH=/tmp/spack
This is a stop-gap approach until we have figured out how to deal with
the system and user config scopes more generally, as there are plans to
potentially / eventually get rid of them.
**User config**
Spack is a bit of a pain when you have:
- a shared $HOME folder across different systems.
- multiple Spack versions on the same system.
**System config**
- On shared systems with a versioned programming environment / toolkit,
system administrators want to provide config for each version (e.g.
21.09, 21.10) of the programming environment, and the user Spack
instance should be able to pick this up without a steep learning
curve.
- On shared systems the user should be able to opt out of the
hard-coded config scope in /etc/spack, since it may be incompatible
with their particular instance. Currently Spack can only opt out of all
config scopes through overrides with `"config:":`, `"packages:":`, but that
also drops the defaults config, which would have to be repeated, which
is undesirable, especially the lengthy packages.yaml.
An example use case is: having config in this folder:
```
/path/to/programming/environment/{version}/{compilers,packages}.yaml
```
and have `module load spack-system-config` set the variable
```
SPACK_SYSTEM_CONFIG_PATH=/path/to/programming/environment/{version}
```
where the user no longer has to worry about what `{version}` they are
on.
**Continuous integration**
Finally, there is the use case of continuous integration, which may
clone an arbitrary Spack version, which optimally should not pick up
system or user config from the previous run (like may happen in
classical bare metal non-containerized filesystem side effect ridden
jenkins pipelines). In fact this is very similar to how spack itself
tries to avoid picking up system dependencies during builds...
**But environments solve this?**
- You could do `include`s in environment files to get similar behavior
to the spack_system_config_path example, but environments require you
to:
1) require paths to individual config files, not directories.
2) fail if the listed config file does not exist
- They allow you to override config scopes, but this is generally too
rigurous, as it requires you to repeat the default config, in
particular packages.yaml, and just defies the point of layered config.
Co-authored-by: Tom Scogland <tscogland@llnl.gov>
Co-authored-by: Tim Fuller <tjfulle@sandia.gov>
Co-authored-by: Steve Leak <sleak@lbl.gov>
Co-authored-by: Todd Gamblin <tgamblin@llnl.gov>
2021-09-29 22:36:28 +08:00
|
|
|
* ``$env``: name of the currently active :ref:`environment <environments>`
|
2018-11-12 02:57:46 +08:00
|
|
|
* ``$spack``: path to the prefix of this Spack installation
|
|
|
|
* ``$tempdir``: default system temporary directory (as specified in
|
|
|
|
Python's `tempfile.tempdir
|
|
|
|
<https://docs.python.org/2/library/tempfile.html#tempfile.tempdir>`_
|
|
|
|
variable.
|
|
|
|
* ``$user``: name of the current user
|
config: overrides for caches and system and user scopes (#26735)
Spack's `system` and `user` scopes provide ways for administrators and
users to set global defaults for all Spack instances, but for use cases
where one wants a clean Spack installation, these scopes can be undesirable.
For example, users may want to opt out of global system configuration, or
they may want to ignore their own home directory settings when running in
a continuous integration environment.
Spack also, by default, keeps various caches and user data in `~/.spack`,
but users may want to override these locations.
Spack provides three environment variables that allow you to override or
opt out of 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.
* `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.
And one that allows you to move the default cache location:
* `SPACK_USER_CACHE_PATH`: Override the default path to use for user data
(misc_cache, tests, reports, etc.)
With these settings, if you want to isolate Spack in a CI environment, you can do this:
export SPACK_DISABLE_LOCAL_CONFIG=true
export SPACK_USER_CACHE_PATH=/tmp/spack
This is a stop-gap approach until we have figured out how to deal with
the system and user config scopes more generally, as there are plans to
potentially / eventually get rid of them.
**User config**
Spack is a bit of a pain when you have:
- a shared $HOME folder across different systems.
- multiple Spack versions on the same system.
**System config**
- On shared systems with a versioned programming environment / toolkit,
system administrators want to provide config for each version (e.g.
21.09, 21.10) of the programming environment, and the user Spack
instance should be able to pick this up without a steep learning
curve.
- On shared systems the user should be able to opt out of the
hard-coded config scope in /etc/spack, since it may be incompatible
with their particular instance. Currently Spack can only opt out of all
config scopes through overrides with `"config:":`, `"packages:":`, but that
also drops the defaults config, which would have to be repeated, which
is undesirable, especially the lengthy packages.yaml.
An example use case is: having config in this folder:
```
/path/to/programming/environment/{version}/{compilers,packages}.yaml
```
and have `module load spack-system-config` set the variable
```
SPACK_SYSTEM_CONFIG_PATH=/path/to/programming/environment/{version}
```
where the user no longer has to worry about what `{version}` they are
on.
**Continuous integration**
Finally, there is the use case of continuous integration, which may
clone an arbitrary Spack version, which optimally should not pick up
system or user config from the previous run (like may happen in
classical bare metal non-containerized filesystem side effect ridden
jenkins pipelines). In fact this is very similar to how spack itself
tries to avoid picking up system dependencies during builds...
**But environments solve this?**
- You could do `include`s in environment files to get similar behavior
to the spack_system_config_path example, but environments require you
to:
1) require paths to individual config files, not directories.
2) fail if the listed config file does not exist
- They allow you to override config scopes, but this is generally too
rigurous, as it requires you to repeat the default config, in
particular packages.yaml, and just defies the point of layered config.
Co-authored-by: Tom Scogland <tscogland@llnl.gov>
Co-authored-by: Tim Fuller <tjfulle@sandia.gov>
Co-authored-by: Steve Leak <sleak@lbl.gov>
Co-authored-by: Todd Gamblin <tgamblin@llnl.gov>
2021-09-29 22:36:28 +08:00
|
|
|
* ``$user_cache_path``: user cache directory (``~/.spack`` unless
|
|
|
|
:ref:`overridden <local-config-overrides>`)
|
2022-11-06 17:11:59 +08:00
|
|
|
* ``$architecture``: the architecture triple of the current host, as
|
|
|
|
detected by Spack.
|
|
|
|
* ``$arch``: alias for ``$architecture``.
|
|
|
|
* ``$platform``: the platform of the current host, as detected by Spack.
|
|
|
|
* ``$operating_system``: the operating system of the current host, as
|
|
|
|
detected by the ``distro`` python module.
|
|
|
|
* ``$os``: alias for ``$operating_system``.
|
|
|
|
* ``$target``: the ISA target for the current host, as detected by
|
|
|
|
ArchSpec. E.g. ``skylake`` or ``neoverse-n1``.
|
|
|
|
* ``$target_family``. The target family for the current host, as
|
|
|
|
detected by ArchSpec. E.g. ``x86_64`` or ``aarch64``.
|
2022-11-15 02:13:30 +08:00
|
|
|
* ``$date``: the current date in the format YYYY-MM-DD
|
|
|
|
|
2017-08-22 09:35:00 +08:00
|
|
|
|
|
|
|
Note that, as with shell variables, you can write these as ``$varname``
|
|
|
|
or with braces to distinguish the variable from surrounding characters:
|
2018-06-24 15:48:02 +08:00
|
|
|
``${varname}``. Their names are also case insensitive, meaning that
|
|
|
|
``$SPACK`` works just as well as ``$spack``. These special variables are
|
|
|
|
substituted first, so any environment variables with the same name will
|
|
|
|
not be used.
|
2017-08-22 09:35:00 +08:00
|
|
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^
|
2018-06-24 15:48:02 +08:00
|
|
|
Environment variables
|
2017-08-22 09:35:00 +08:00
|
|
|
^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
After Spack-specific variables are evaluated, environment variables are
|
|
|
|
expanded. These are formatted like Spack-specific variables, e.g.,
|
|
|
|
``${varname}``. You can use this to insert environment variables in your
|
2018-06-24 15:48:02 +08:00
|
|
|
Spack configuration.
|
2017-08-22 09:35:00 +08:00
|
|
|
|
2018-06-24 15:48:02 +08:00
|
|
|
^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
User home directories
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
2018-11-12 02:57:46 +08:00
|
|
|
Spack performs Unix-style tilde expansion on paths in configuration
|
|
|
|
files. This means that tilde (``~``) will expand to the current user's
|
2018-06-24 15:48:02 +08:00
|
|
|
home directory, and ``~user`` will expand to a specified user's home
|
2018-11-12 02:57:46 +08:00
|
|
|
directory. The ``~`` must appear at the beginning of the path, or Spack
|
2018-06-24 15:48:02 +08:00
|
|
|
will not expand it.
|
|
|
|
|
2020-01-28 00:40:47 +08:00
|
|
|
.. _configuration_environment_variables:
|
|
|
|
|
|
|
|
-------------------------
|
|
|
|
Environment Modifications
|
|
|
|
-------------------------
|
|
|
|
|
|
|
|
Spack allows to prescribe custom environment modifications in a few places
|
|
|
|
within its configuration files. Every time these modifications are allowed
|
|
|
|
they are specified as a dictionary, like in the following example:
|
|
|
|
|
|
|
|
.. code-block:: yaml
|
|
|
|
|
|
|
|
environment:
|
|
|
|
set:
|
|
|
|
LICENSE_FILE: '/path/to/license'
|
|
|
|
unset:
|
|
|
|
- CPATH
|
|
|
|
- LIBRARY_PATH
|
|
|
|
append_path:
|
|
|
|
PATH: '/new/bin/dir'
|
|
|
|
|
|
|
|
The possible actions that are permitted are ``set``, ``unset``, ``append_path``,
|
|
|
|
``prepend_path`` and finally ``remove_path``. They all require a dictionary
|
|
|
|
of variable names mapped to the values used for the modification.
|
|
|
|
The only exception is ``unset`` that requires just a list of variable names.
|
|
|
|
No particular order is ensured on the execution of each of these modifications.
|
|
|
|
|
2018-06-24 15:48:02 +08:00
|
|
|
----------------------------
|
2018-11-12 02:57:46 +08:00
|
|
|
Seeing Spack's Configuration
|
2018-06-24 15:48:02 +08:00
|
|
|
----------------------------
|
|
|
|
|
|
|
|
With so many scopes overriding each other, it can sometimes be difficult
|
2018-06-24 15:49:18 +08:00
|
|
|
to understand what Spack's final configuration looks like.
|
|
|
|
|
|
|
|
Spack provides two useful ways to view the final "merged" version of any
|
|
|
|
configuration file: ``spack config get`` and ``spack config blame``.
|
|
|
|
|
|
|
|
.. _cmd-spack-config-get:
|
|
|
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^
|
|
|
|
``spack config get``
|
|
|
|
^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
``spack config get`` shows a fully merged configuration file, taking into
|
2018-11-12 02:57:46 +08:00
|
|
|
account all scopes. For example, to see the fully merged
|
2018-06-24 15:49:18 +08:00
|
|
|
``config.yaml``, you can type:
|
2018-06-24 15:48:02 +08:00
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ spack config get config
|
|
|
|
config:
|
|
|
|
debug: false
|
|
|
|
checksum: true
|
|
|
|
verify_ssl: true
|
|
|
|
dirty: false
|
|
|
|
build_jobs: 8
|
|
|
|
install_tree: $spack/opt/spack
|
|
|
|
template_dirs:
|
|
|
|
- $spack/templates
|
2019-04-18 09:21:40 +08:00
|
|
|
directory_layout: {architecture}/{compiler.name}-{compiler.version}/{name}-{version}-{hash}
|
2018-06-24 15:48:02 +08:00
|
|
|
build_stage:
|
2019-09-04 07:31:27 +08:00
|
|
|
- $tempdir/$user/spack-stage
|
|
|
|
- ~/.spack/stage
|
2018-06-24 15:48:02 +08:00
|
|
|
- $spack/var/spack/stage
|
|
|
|
source_cache: $spack/var/spack/cache
|
|
|
|
misc_cache: ~/.spack/cache
|
|
|
|
locks: true
|
|
|
|
|
|
|
|
Likewise, this will show the fully merged ``packages.yaml``:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ spack config get packages
|
|
|
|
|
|
|
|
You can use this in conjunction with the ``-C`` / ``--config-scope`` argument to
|
|
|
|
see how your scope will affect Spack's configuration:
|
|
|
|
|
|
|
|
.. code-block:: console
|
2017-08-22 09:35:00 +08:00
|
|
|
|
2018-06-24 15:48:02 +08:00
|
|
|
$ spack -C /path/to/my/scope config get packages
|
2018-06-24 15:49:18 +08:00
|
|
|
|
|
|
|
|
|
|
|
.. _cmd-spack-config-blame:
|
|
|
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
``spack config blame``
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
``spack config blame`` functions much like ``spack config get``, but it
|
|
|
|
shows exactly which configuration file each preference came from. If you
|
|
|
|
do not know why Spack is behaving a certain way, this can help you track
|
|
|
|
down the problem:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ spack --insecure -C ./my-scope -C ./my-scope-2 config blame config
|
|
|
|
==> Warning: You asked for --insecure. Will NOT check SSL certificates.
|
|
|
|
--- config:
|
|
|
|
_builtin debug: False
|
|
|
|
/home/myuser/spack/etc/spack/defaults/config.yaml:72 checksum: True
|
|
|
|
command_line verify_ssl: False
|
|
|
|
./my-scope-2/config.yaml:2 dirty: False
|
|
|
|
_builtin build_jobs: 8
|
|
|
|
./my-scope/config.yaml:2 install_tree: /path/to/some/tree
|
|
|
|
/home/myuser/spack/etc/spack/defaults/config.yaml:23 template_dirs:
|
|
|
|
/home/myuser/spack/etc/spack/defaults/config.yaml:24 - $spack/templates
|
2019-04-18 09:21:40 +08:00
|
|
|
/home/myuser/spack/etc/spack/defaults/config.yaml:28 directory_layout: {architecture}/{compiler.name}-{compiler.version}/{name}-{version}-{hash}
|
2018-06-24 15:49:18 +08:00
|
|
|
/home/myuser/spack/etc/spack/defaults/config.yaml:49 build_stage:
|
2019-09-04 07:31:27 +08:00
|
|
|
/home/myuser/spack/etc/spack/defaults/config.yaml:50 - $tempdir/$user/spack-stage
|
|
|
|
/home/myuser/spack/etc/spack/defaults/config.yaml:51 - ~/.spack/stage
|
2018-06-24 15:49:18 +08:00
|
|
|
/home/myuser/spack/etc/spack/defaults/config.yaml:52 - $spack/var/spack/stage
|
|
|
|
/home/myuser/spack/etc/spack/defaults/config.yaml:57 source_cache: $spack/var/spack/cache
|
|
|
|
/home/myuser/spack/etc/spack/defaults/config.yaml:62 misc_cache: ~/.spack/cache
|
|
|
|
/home/myuser/spack/etc/spack/defaults/config.yaml:86 locks: True
|
|
|
|
|
|
|
|
You can see above that the ``build_jobs`` and ``debug`` settings are
|
2018-11-12 02:57:46 +08:00
|
|
|
built in and are not overridden by a configuration file. The
|
2022-11-05 03:19:34 +08:00
|
|
|
``verify_ssl`` setting comes from the ``--insecure`` option on the
|
2018-11-12 02:57:46 +08:00
|
|
|
command line. ``dirty`` and ``install_tree`` come from the custom
|
2018-06-24 15:49:18 +08:00
|
|
|
scopes ``./my-scope`` and ``./my-scope-2``, and all other configuration
|
|
|
|
options come from the default configuration files that ship with Spack.
|
config: overrides for caches and system and user scopes (#26735)
Spack's `system` and `user` scopes provide ways for administrators and
users to set global defaults for all Spack instances, but for use cases
where one wants a clean Spack installation, these scopes can be undesirable.
For example, users may want to opt out of global system configuration, or
they may want to ignore their own home directory settings when running in
a continuous integration environment.
Spack also, by default, keeps various caches and user data in `~/.spack`,
but users may want to override these locations.
Spack provides three environment variables that allow you to override or
opt out of 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.
* `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.
And one that allows you to move the default cache location:
* `SPACK_USER_CACHE_PATH`: Override the default path to use for user data
(misc_cache, tests, reports, etc.)
With these settings, if you want to isolate Spack in a CI environment, you can do this:
export SPACK_DISABLE_LOCAL_CONFIG=true
export SPACK_USER_CACHE_PATH=/tmp/spack
This is a stop-gap approach until we have figured out how to deal with
the system and user config scopes more generally, as there are plans to
potentially / eventually get rid of them.
**User config**
Spack is a bit of a pain when you have:
- a shared $HOME folder across different systems.
- multiple Spack versions on the same system.
**System config**
- On shared systems with a versioned programming environment / toolkit,
system administrators want to provide config for each version (e.g.
21.09, 21.10) of the programming environment, and the user Spack
instance should be able to pick this up without a steep learning
curve.
- On shared systems the user should be able to opt out of the
hard-coded config scope in /etc/spack, since it may be incompatible
with their particular instance. Currently Spack can only opt out of all
config scopes through overrides with `"config:":`, `"packages:":`, but that
also drops the defaults config, which would have to be repeated, which
is undesirable, especially the lengthy packages.yaml.
An example use case is: having config in this folder:
```
/path/to/programming/environment/{version}/{compilers,packages}.yaml
```
and have `module load spack-system-config` set the variable
```
SPACK_SYSTEM_CONFIG_PATH=/path/to/programming/environment/{version}
```
where the user no longer has to worry about what `{version}` they are
on.
**Continuous integration**
Finally, there is the use case of continuous integration, which may
clone an arbitrary Spack version, which optimally should not pick up
system or user config from the previous run (like may happen in
classical bare metal non-containerized filesystem side effect ridden
jenkins pipelines). In fact this is very similar to how spack itself
tries to avoid picking up system dependencies during builds...
**But environments solve this?**
- You could do `include`s in environment files to get similar behavior
to the spack_system_config_path example, but environments require you
to:
1) require paths to individual config files, not directories.
2) fail if the listed config file does not exist
- They allow you to override config scopes, but this is generally too
rigurous, as it requires you to repeat the default config, in
particular packages.yaml, and just defies the point of layered config.
Co-authored-by: Tom Scogland <tscogland@llnl.gov>
Co-authored-by: Tim Fuller <tjfulle@sandia.gov>
Co-authored-by: Steve Leak <sleak@lbl.gov>
Co-authored-by: Todd Gamblin <tgamblin@llnl.gov>
2021-09-29 22:36:28 +08:00
|
|
|
|
|
|
|
.. _local-config-overrides:
|
|
|
|
|
|
|
|
------------------------------
|
|
|
|
Overriding Local Configuration
|
|
|
|
------------------------------
|
|
|
|
|
|
|
|
Spack's ``system`` and ``user`` scopes provide ways for administrators and users to set
|
|
|
|
global defaults for all Spack instances, but for use cases where one wants a clean Spack
|
|
|
|
installation, these scopes can be undesirable. For example, users may want to opt out of
|
|
|
|
global system configuration, or they may want to ignore their own home directory
|
|
|
|
settings when running in a continuous integration environment.
|
|
|
|
|
|
|
|
Spack also, by default, keeps various caches and user data in ``~/.spack``, but
|
|
|
|
users may want to override these locations.
|
|
|
|
|
|
|
|
Spack provides three environment variables that allow you to override or opt out of
|
|
|
|
configuration locations:
|
|
|
|
|
|
|
|
* ``SPACK_USER_CONFIG_PATH``: Override the path to use for the
|
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.
2021-10-29 05:33:44 +08:00
|
|
|
``user`` scope (``~/.spack`` by default).
|
|
|
|
* ``SPACK_SYSTEM_CONFIG_PATH``: Override the path to use for the
|
|
|
|
``system`` scope (``/etc/spack`` by default).
|
config: overrides for caches and system and user scopes (#26735)
Spack's `system` and `user` scopes provide ways for administrators and
users to set global defaults for all Spack instances, but for use cases
where one wants a clean Spack installation, these scopes can be undesirable.
For example, users may want to opt out of global system configuration, or
they may want to ignore their own home directory settings when running in
a continuous integration environment.
Spack also, by default, keeps various caches and user data in `~/.spack`,
but users may want to override these locations.
Spack provides three environment variables that allow you to override or
opt out of 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.
* `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.
And one that allows you to move the default cache location:
* `SPACK_USER_CACHE_PATH`: Override the default path to use for user data
(misc_cache, tests, reports, etc.)
With these settings, if you want to isolate Spack in a CI environment, you can do this:
export SPACK_DISABLE_LOCAL_CONFIG=true
export SPACK_USER_CACHE_PATH=/tmp/spack
This is a stop-gap approach until we have figured out how to deal with
the system and user config scopes more generally, as there are plans to
potentially / eventually get rid of them.
**User config**
Spack is a bit of a pain when you have:
- a shared $HOME folder across different systems.
- multiple Spack versions on the same system.
**System config**
- On shared systems with a versioned programming environment / toolkit,
system administrators want to provide config for each version (e.g.
21.09, 21.10) of the programming environment, and the user Spack
instance should be able to pick this up without a steep learning
curve.
- On shared systems the user should be able to opt out of the
hard-coded config scope in /etc/spack, since it may be incompatible
with their particular instance. Currently Spack can only opt out of all
config scopes through overrides with `"config:":`, `"packages:":`, but that
also drops the defaults config, which would have to be repeated, which
is undesirable, especially the lengthy packages.yaml.
An example use case is: having config in this folder:
```
/path/to/programming/environment/{version}/{compilers,packages}.yaml
```
and have `module load spack-system-config` set the variable
```
SPACK_SYSTEM_CONFIG_PATH=/path/to/programming/environment/{version}
```
where the user no longer has to worry about what `{version}` they are
on.
**Continuous integration**
Finally, there is the use case of continuous integration, which may
clone an arbitrary Spack version, which optimally should not pick up
system or user config from the previous run (like may happen in
classical bare metal non-containerized filesystem side effect ridden
jenkins pipelines). In fact this is very similar to how spack itself
tries to avoid picking up system dependencies during builds...
**But environments solve this?**
- You could do `include`s in environment files to get similar behavior
to the spack_system_config_path example, but environments require you
to:
1) require paths to individual config files, not directories.
2) fail if the listed config file does not exist
- They allow you to override config scopes, but this is generally too
rigurous, as it requires you to repeat the default config, in
particular packages.yaml, and just defies the point of layered config.
Co-authored-by: Tom Scogland <tscogland@llnl.gov>
Co-authored-by: Tim Fuller <tjfulle@sandia.gov>
Co-authored-by: Steve Leak <sleak@lbl.gov>
Co-authored-by: Todd Gamblin <tgamblin@llnl.gov>
2021-09-29 22:36:28 +08:00
|
|
|
* ``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.
|
|
|
|
|
|
|
|
And one that allows you to move the default cache location:
|
|
|
|
|
|
|
|
* ``SPACK_USER_CACHE_PATH``: Override the default path to use for user data
|
|
|
|
(misc_cache, tests, reports, etc.)
|
|
|
|
|
|
|
|
With these settings, if you want to isolate Spack in a CI environment, you can do this::
|
|
|
|
|
|
|
|
export SPACK_DISABLE_LOCAL_CONFIG=true
|
|
|
|
export SPACK_USER_CACHE_PATH=/tmp/spack
|