summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2024-03-14 21:47:56 +0100
committerGitHub <noreply@github.com>2024-03-14 13:47:56 -0700
commit8f56eb620f0ec6d2dc3d73f442d6eeb7ed986558 (patch)
tree7796c8d34f08de67511af1fe5e05846a32746a25 /lib
parentec517b40e98dabb5759553f1d2599e50f245018a (diff)
downloadspack-8f56eb620f0ec6d2dc3d73f442d6eeb7ed986558.tar.gz
spack-8f56eb620f0ec6d2dc3d73f442d6eeb7ed986558.tar.bz2
spack-8f56eb620f0ec6d2dc3d73f442d6eeb7ed986558.tar.xz
spack-8f56eb620f0ec6d2dc3d73f442d6eeb7ed986558.zip
Improve error message when an unknown compiler is requested (#43143)
Fixes #43141
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/solver/asp.py5
-rw-r--r--lib/spack/spack/solver/concretize.lp10
-rw-r--r--lib/spack/spack/test/concretize.py9
3 files changed, 18 insertions, 6 deletions
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py
index 0ae359c006..c2524b1223 100644
--- a/lib/spack/spack/solver/asp.py
+++ b/lib/spack/spack/solver/asp.py
@@ -823,11 +823,12 @@ class PyclingoDriver:
print("Statistics:")
pprint.pprint(self.control.statistics)
- if result.unsolved_specs and setup.concretize_everything:
+ if result.satisfiable and result.unsolved_specs and setup.concretize_everything:
unsolved_str = Result.format_unsolved(result.unsolved_specs)
raise InternalConcretizerError(
"Internal Spack error: the solver completed but produced specs"
- f" that do not satisfy the request.\n\t{unsolved_str}"
+ " that do not satisfy the request. Please report a bug at "
+ f"https://github.com/spack/spack/issues\n\t{unsolved_str}"
)
return result, timer, self.control.statistics
diff --git a/lib/spack/spack/solver/concretize.lp b/lib/spack/spack/solver/concretize.lp
index 7f06d6f3a9..6736dcaf45 100644
--- a/lib/spack/spack/solver/concretize.lp
+++ b/lib/spack/spack/solver/concretize.lp
@@ -1172,11 +1172,13 @@ attr("node_compiler_version_satisfies", PackageNode, Compiler, Constraint)
% If the compiler version was set from the command line,
% respect it verbatim
-:- attr("node_compiler_version_set", PackageNode, Compiler, Version),
- not attr("node_compiler_version", PackageNode, Compiler, Version).
+error(100, "Cannot set the required compiler: {2}%{0}@{1}", Compiler, Version, Package)
+ :- attr("node_compiler_version_set", node(X, Package), Compiler, Version),
+ not attr("node_compiler_version", node(X, Package), Compiler, Version).
-:- attr("node_compiler_set", PackageNode, Compiler),
- not attr("node_compiler_version", PackageNode, Compiler, _).
+error(100, "Cannot set the required compiler: {1}%{0}", Compiler, Package)
+ :- attr("node_compiler_set", node(X, Package), Compiler),
+ not attr("node_compiler_version", node(X, Package), Compiler, _).
% Cannot select a compiler if it is not supported on the OS
% Compilers that are explicitly marked as allowed
diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py
index 1c1444423b..b12fbfb910 100644
--- a/lib/spack/spack/test/concretize.py
+++ b/lib/spack/spack/test/concretize.py
@@ -2114,6 +2114,15 @@ class TestConcretize:
):
solver.driver.solve(setup, specs, reuse=[])
+ @pytest.mark.regression("43141")
+ @pytest.mark.only_clingo("Use case not supported by the original concretizer")
+ def test_clear_error_when_unknown_compiler_requested(self, mock_packages, config):
+ """Tests that the solver can report a case where the compiler cannot be set"""
+ with pytest.raises(
+ spack.error.UnsatisfiableSpecError, match="Cannot set the required compiler: a%foo"
+ ):
+ Spec("a %foo").concretized()
+
@pytest.mark.regression("36339")
def test_compiler_match_constraints_when_selected(self):
"""Test that, when multiple compilers with the same name are in the configuration