diff --git a/var/spack/repos/builtin/packages/libxpm/package.py b/var/spack/repos/builtin/packages/libxpm/package.py index 7cc339f92c..24a49f0436 100644 --- a/var/spack/repos/builtin/packages/libxpm/package.py +++ b/var/spack/repos/builtin/packages/libxpm/package.py @@ -27,5 +27,9 @@ class Libxpm(AutotoolsPackage): depends_on('util-macros', type='build') def setup_environment(self, spack_env, run_env): - spack_env.append_flags('LDFLAGS', '-L{0} -lintl'.format( - self.spec['gettext'].prefix.lib)) + # If libxpm is installed as an external package, gettext won't + # be available in the spec. See + # https://github.com/spack/spack/issues/9149 for details. + if 'gettext' in self.spec: + spack_env.append_flags('LDFLAGS', '-L{0} -lintl'.format( + self.spec['gettext'].prefix.lib))