Frequently Asked Questions
This page contains answers to frequently asked questions about Spack. If you have questions that are not answered here, feel free to ask on Slack or GitHub Discussions. If you’ve learned the answer to a question that you think should be here, please consider contributing to this page.
Why does Spack pick particular versions and variants?
This question comes up in a variety of forms:
Why does Spack seem to ignore my package preferences from
packages.yaml
config?Why does Spack toggle a variant instead of using the default from the
package.py
file?
The short answer is that Spack always picks an optimal configuration based on a complex set of criteria[1]. These criteria are more nuanced than always choosing the latest versions or default variants.
Note
As a rule of thumb: requirements + constraints > reuse > preferences > defaults.
The following set of criteria (from lowest to highest precedence) explain common cases where concretization output may seem surprising at first.
Package preferences configured in
packages.yaml
override variant defaults frompackage.py
files, and influence the optimal ordering of versions. Preferences are specified as follows:packages: foo: version: [1.0, 1.1] variants: ~mpi
Reuse concretization configured in
concretizer.yaml
overrides preferences, since it’s typically faster to reuse an existing spec than to build a preferred one from sources. When build caches are enabled, specs may be reused from a remote location too. Reuse concretization is configured as follows:concretizer: reuse: dependencies # other options are 'true' and 'false'
Package requirements configured in
packages.yaml
, and constraints from the command line as well aspackage.py
files override all of the above. Requirements are specified as follows:packages: foo: require: - "@1.2: +mpi"
Requirements and constraints restrict the set of possible solutions, while reuse behavior and preferences influence what an optimal solution looks like.
Footnotes