summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeth R. Johnson <johnsonsr@ornl.gov>2022-05-24 17:52:40 +0200
committerGitHub <noreply@github.com>2022-05-24 08:52:40 -0700
commit6a57aede571873f1dac2359dc3e6f430a1fcd900 (patch)
tree1213f2ea65f4c1c005a31012acbbc0fbd738541e
parentba701a7cf8c60a85a317dcde63083fc76061c7d6 (diff)
downloadspack-6a57aede571873f1dac2359dc3e6f430a1fcd900.tar.gz
spack-6a57aede571873f1dac2359dc3e6f430a1fcd900.tar.bz2
spack-6a57aede571873f1dac2359dc3e6f430a1fcd900.tar.xz
spack-6a57aede571873f1dac2359dc3e6f430a1fcd900.zip
environments: fail gracefully on missing keys (#26378)
-rw-r--r--lib/spack/spack/environment/environment.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/spack/spack/environment/environment.py b/lib/spack/spack/environment/environment.py
index 2536186b63..b275dd02f2 100644
--- a/lib/spack/spack/environment/environment.py
+++ b/lib/spack/spack/environment/environment.py
@@ -1619,7 +1619,14 @@ class Environment(object):
"""Return all specs, even those a user spec would shadow."""
all_specs = set()
for h in self.concretized_order:
- all_specs.update(self.specs_by_hash[h].traverse())
+ try:
+ spec = self.specs_by_hash[h]
+ except KeyError:
+ tty.warn(
+ 'Environment %s appears to be corrupt: missing spec '
+ '"%s"' % (self.name, h))
+ continue
+ all_specs.update(spec.traverse())
return sorted(all_specs)