summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/package_base.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/spack/spack/package_base.py b/lib/spack/spack/package_base.py
index 0be36f08ea..7c17c7d02e 100644
--- a/lib/spack/spack/package_base.py
+++ b/lib/spack/spack/package_base.py
@@ -2555,7 +2555,12 @@ class PackageStillNeededError(InstallError):
"""Raised when package is still needed by another on uninstall."""
def __init__(self, spec, dependents):
- super().__init__("Cannot uninstall %s" % spec)
+ spec_fmt = spack.spec.DEFAULT_FORMAT + " /{hash:7}"
+ dep_fmt = "{name}{@versions} /{hash:7}"
+ super().__init__(
+ f"Cannot uninstall {spec.format(spec_fmt)}, "
+ f"needed by {[dep.format(dep_fmt) for dep in dependents]}"
+ )
self.spec = spec
self.dependents = dependents