From c264cf12a21c44358739fbe1fa674d2cb497ab5d Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Tue, 14 Nov 2023 02:25:56 -0600 Subject: dd4hep: avoid IndexError in setup_run_environment (#41051) Some environments may have `dd4hep` as a concretized package without having it installed (yet). For those environments, `dd4hep` has property `libs` that is an empty list. Nevertheless, it can be added to a run environment (for example in case `dd4hep` is part of an environment). This results in an IndexError: ``` ==> Warning: couldn't load runtime environment due to IndexError: list index out of range ``` To avoid the IndexError, only prepend the `dd4hep` libs if there are actually libs found. --- var/spack/repos/builtin/packages/dd4hep/package.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'var') diff --git a/var/spack/repos/builtin/packages/dd4hep/package.py b/var/spack/repos/builtin/packages/dd4hep/package.py index 77c3934bdf..a9ca9fe12d 100644 --- a/var/spack/repos/builtin/packages/dd4hep/package.py +++ b/var/spack/repos/builtin/packages/dd4hep/package.py @@ -254,7 +254,8 @@ class Dd4hep(CMakePackage): env.set("DD4HEP", self.prefix.examples) env.set("DD4hep_DIR", self.prefix) env.set("DD4hep_ROOT", self.prefix) - env.prepend_path("LD_LIBRARY_PATH", self.libs.directories[0]) + if len(self.libs.directories) > 0: + env.prepend_path("LD_LIBRARY_PATH", self.libs.directories[0]) def url_for_version(self, version): # dd4hep releases are dashes and padded with a leading zero -- cgit v1.2.3-60-g2f50