From 2c43131acacc33deee25b4269d279d002c4a9f7a Mon Sep 17 00:00:00 2001 From: Gregory Becker Date: Tue, 22 Apr 2025 17:43:30 -0700 Subject: [PATCH] bugfix for error message when input spec does not satisfy concretizer output Signed-off-by: Gregory Becker --- lib/spack/spack/main.py | 13 +++++++------ lib/spack/spack/test/concretization/errors.py | 6 ++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/spack/spack/main.py b/lib/spack/spack/main.py index d55f5ec9c4c..5939715b0ac 100644 --- a/lib/spack/spack/main.py +++ b/lib/spack/spack/main.py @@ -1090,12 +1090,13 @@ def _handle_solver_bug( stream=out, ) if wrong_output: - msg = ( - "internal solver error: the following specs were concretized, but do not satisfy the " - "input:\n - " - + "\n - ".join(str(s) for s, _ in wrong_output) - + "\n Please report a bug at https://github.com/spack/spack/issues" - ) + msg = "internal solver error: the following specs were concretized, but do not satisfy " + msg += "the input:\n" + for in_spec, out_spec in wrong_output: + msg += f" - input: {in_spec}\n" + msg += f" output: {out_spec.long_spec}\n" + msg += "\n Please report a bug at https://github.com/spack/spack/issues" + # try to write the input/output specs to a temporary directory for bug reports try: tmpdir = tempfile.mkdtemp(prefix="spack-asp-", dir=root) diff --git a/lib/spack/spack/test/concretization/errors.py b/lib/spack/spack/test/concretization/errors.py index 779a84419ff..62a28a3160c 100644 --- a/lib/spack/spack/test/concretization/errors.py +++ b/lib/spack/spack/test/concretization/errors.py @@ -81,8 +81,10 @@ def test_internal_error_handling_formatting(tmp_path): assert "the following specs were not solved:\n - baz+z\n" in output assert ( "the following specs were concretized, but do not satisfy the input:\n" - " - foo+x\n" - " - bar+y\n" + " - input: foo+x\n" + " output: foo@=1.0~x\n" + " - input: bar+y\n" + " output: x@=1.0~y" ) in output files = {f.name: str(f) for f in tmp_path.glob("spack-asp-*/*.json")}