From 101693d8233b97e6af986534ff3d8a647de0094d Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Thu, 17 Aug 2017 08:26:04 +0200 Subject: [PATCH] Improved error message for unsatisfiable specs (#5113) * Improved error message for unsatisfiable specs. fixes #5066 This PR improves the error message for unsatisfiable specs by showing in tree format both the spec that cannot satisfy the constraint and the spec that asked for that constraint. After that follows a readable error message. --- lib/spack/spack/spec.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 32e08d38964..05db84806f6 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -1985,10 +1985,19 @@ def _merge_dependency(self, dep, deptypes, visited, spec_deps, try: changed |= spec_deps[dep.name].constrain(dep) except UnsatisfiableSpecError as e: - e.message = "Invalid spec: '%s'. " - e.message += "Package %s requires %s %s, but spec asked for %s" - e.message %= (spec_deps[dep.name], dep.name, - e.constraint_type, e.required, e.provided) + fmt = 'An unsatisfiable {0}'.format(e.constraint_type) + fmt += ' constraint has been detected for spec:' + fmt += '\n\n{0}\n\n'.format(spec_deps[dep.name].tree(indent=4)) + fmt += 'while trying to concretize the partial spec:' + fmt += '\n\n{0}\n\n'.format(self.tree(indent=4)) + fmt += '{0} requires {1} {2} {3}, but spec asked for {4}' + e.message = fmt.format( + self.name, + dep.name, + e.constraint_type, + e.required, + e.provided + ) raise e # Add merged spec to my deps and recurse