diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index 89d5fce628e..438e753ee9a 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -626,9 +626,9 @@ def _get_cause_tree(self, cause, conditions, condition_causes, literals, indent= ) ] - def get_cause_tree(self, cause): - conditions = dict(extract_args(self.model, "condition")) - condition_causes = list(extract_args(self.model, "condition_cause")) + def get_cause_tree(self, result, best_model, cause): + conditions = dict(extract_args(best_model, "condition")) + condition_causes = list(extract_args(best_model, "condition_cause")) return self._get_cause_tree(cause, conditions, condition_causes, []) def handle_error(self, msg, *args): @@ -650,10 +650,6 @@ def handle_error(self, msg, *args): msg = msg.format(*msg_args) - for cause in set(cause_args): - for c in self.get_cause_tree(cause): - msg += f"\n{c}" - # For variant formatting, we sometimes have to construct specs # to format values properly. Find/replace all occurances of # Spec(...) with the string representation of the spec mentioned @@ -661,6 +657,10 @@ def handle_error(self, msg, *args): for spec_str in specs_to_construct: msg = msg.replace("Spec(%s)" % spec_str, str(spack.spec.Spec(spec_str))) + for cause in set(cause_args): + for c in self.get_cause_tree(cause): + msg += f"\n{c}" + return msg def message(self, errors) -> str: