Repository: spack/spack

Issue:
Installation issue: pango
### Steps to reproduce the issue

```console
Input spec
--------------------------------
pango@1.50.7

Concretized
--------------------------------
pango@1.50.7%gcc@12.1.0+X~strip buildtype=debugoptimized default_library=shared arch=linux-centos8-x86_64_v3
    ^cairo@1.16.0%gcc@12.1.0+X+fc+ft+gobject+pdf+png~svg patches=7c4da77 arch=linux-centos8-x86_64_v3
        ^autoconf@2.69%gcc@12.1.0 patches=35c4492,7793209,a49dd5b arch=linux-centos8-x86_64_v3
            ^m4@1.4.19%gcc@12.1.0+sigsegv patches=9dc5fbd,bfdffa7 arch=linux-centos8-x86_64_v3
                ^libsigsegv@2.13%gcc@12.1.0 arch=linux-centos8-x86_64_v3
            ^perl@5.34.1%gcc@12.1.0+cpanm+shared+threads arch=linux-centos8-x86_64_v3
                ^berkeley-db@18.1.40%gcc@12.1.0+cxx~docs+stl patches=b231fcc arch=linux-centos8-x86_64_v3
                ^bzip2@1.0.8%gcc@12.1.0~debug~pic+shared arch=linux-centos8-x86_64_v3
                    ^diffutils@3.8%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                        ^libiconv@1.16%gcc@12.1.0 libs=shared,static arch=linux-centos8-x86_64_v3
                ^gdbm@1.19%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                    ^readline@8.1%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                        ^ncurses@6.2%gcc@12.1.0~symlinks+termlib abi=none arch=linux-centos8-x86_64_v3
                            ^pkgconf@1.8.0%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                ^zlib@1.2.12%gcc@12.1.0+optimize+pic+shared patches=0d38234 arch=linux-centos8-x86_64_v3
        ^automake@1.16.5%gcc@12.1.0 arch=linux-centos8-x86_64_v3
        ^fontconfig@2.13.94%gcc@12.1.0 arch=linux-centos8-x86_64_v3
            ^font-util@1.3.2%gcc@12.1.0 fonts=encodings,font-adobe-100dpi,font-adobe-75dpi,font-adobe-utopia-100dpi,font-adobe-utopia-75dpi,font-adobe-utopia-type1,font-alias,font-arabic-misc,font-bh-100dpi,font-bh-75dpi,font-bh-lucidatypewriter-100dpi,font-bh-lucidatypewriter-75dpi,font-bh-type1,font-bitstream-100dpi,font-bitstream-75dpi,font-bitstream-speedo,font-bitstream-type1,font-cronyx-cyrillic,font-cursor-misc,font-daewoo-misc,font-dec-misc,font-ibm-type1,font-isas-misc,font-jis-misc,font-micro-misc,font-misc-cyrillic,font-misc-ethiopic,font-misc-meltho,font-misc-misc,font-mutt-misc,font-schumacher-misc,font-screen-cyrillic,font-sun-misc,font-winitzki-cyrillic,font-xfree86-type1 arch=linux-centos8-x86_64_v3
                ^bdftopcf@1.0.5%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                    ^fontsproto@2.1.3%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                        ^util-macros@1.19.3%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                    ^libxfont@1.5.2%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                        ^freetype@2.11.1%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                            ^libpng@1.6.37%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                        ^libfontenc@1.1.3%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                            ^xproto@7.0.31%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                        ^xtrans@1.3.5%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                ^mkfontdir@1.0.7%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                    ^mkfontscale@1.1.2%gcc@12.1.0 arch=linux-centos8-x86_64_v3
            ^gperf@3.1%gcc@12.1.0 arch=linux-centos8-x86_64_v3
            ^libxml2@2.9.13%gcc@12.1.0~python arch=linux-centos8-x86_64_v3
                ^xz@5.2.5%gcc@12.1.0~pic libs=shared,static arch=linux-centos8-x86_64_v3
            ^python@3.9.12%gcc@12.1.0+bz2+ctypes+dbm~debug+ensurepip+libxml2+lzma~nis~optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tix~tkinter~ucs4+uuid+zlib patches=0d98e93,4c24573,f2fd060 arch=linux-centos8-x86_64_v3
                ^expat@2.4.8%gcc@12.1.0+libbsd arch=linux-centos8-x86_64_v3
                    ^libbsd@0.11.5%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                        ^libmd@1.0.4%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                ^gettext@0.21%gcc@12.1.0+bzip2+curses+git~libunistring+libxml2+tar+xz arch=linux-centos8-x86_64_v3
                    ^tar@1.34%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                ^libffi@3.3%gcc@12.1.0 patches=26f26c6 arch=linux-centos8-x86_64_v3
                ^openssl@1.1.1o%gcc@12.1.0~docs~shared certs=system arch=linux-centos8-x86_64_v3
                    ^perl@5.34.1%gcc@12.1.0+cpanm+shared+threads arch=linux-centos8-x86_64_v3
                        ^berkeley-db@18.1.40%gcc@12.1.0+cxx~docs+stl patches=b231fcc arch=linux-centos8-x86_64_v3
                        ^bzip2@1.0.8%gcc@12.1.0~debug~pic+shared arch=linux-centos8-x86_64_v3
                            ^diffutils@3.8%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                                ^libiconv@1.16%gcc@12.1.0 libs=shared,static arch=linux-centos8-x86_64_v3
                        ^gdbm@1.19%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                            ^readline@8.1%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                                ^ncurses@6.2%gcc@12.1.0~symlinks+termlib abi=none arch=linux-centos8-x86_64_v3
                                    ^pkgconf@1.8.0%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                ^sqlite@3.38.5%gcc@12.1.0+column_metadata+dynamic_extensions+fts~functions+rtree arch=linux-centos8-x86_64_v3
                ^util-linux-uuid@2.37.4%gcc@12.1.0 arch=linux-centos8-x86_64_v3
        ^glib@2.72.1%gcc@12.1.0~libmount patches=b3fd450 tracing=none arch=linux-centos8-x86_64_v3
            ^meson@0.62.1%gcc@12.1.0 patches=aa6c50d arch=linux-centos8-x86_64_v3
                ^ninja@1.10.2%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                ^py-pip@21.3.1%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                ^py-setuptools@57.4.0%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                    ^py-wheel@0.37.0%gcc@12.1.0 arch=linux-centos8-x86_64_v3
            ^pcre@8.45%gcc@12.1.0+jit+multibyte+utf arch=linux-centos8-x86_64_v3
        ^libtool@2.4.7%gcc@12.1.0 arch=linux-centos8-x86_64_v3
        ^libx11@1.7.0%gcc@12.1.0 arch=linux-centos8-x86_64_v3
            ^inputproto@2.3.2%gcc@12.1.0 arch=linux-centos8-x86_64_v3
            ^kbproto@1.0.7%gcc@12.1.0 arch=linux-centos8-x86_64_v3
            ^libxcb@1.14%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                ^libpthread-stubs@0.4%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                ^libxau@1.0.8%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                ^libxdmcp@1.1.2%gcc@12.1.0 arch=linux-centos8-x86_64_v3
                ^xcb-proto@1.14.1%gcc@12.1.0 arch=linux-centos8-x86_64_v3
            ^xextproto@7.3.0%gcc@12.1.0 arch=linux-centos8-x86_64_v3
        ^libxext@1.3.3%gcc@12.1.0 arch=linux-centos8-x86_64_v3
        ^libxrender@0.9.10%gcc@12.1.0 arch=linux-centos8-x86_64_v3
            ^renderproto@0.11.1%gcc@12.1.0 arch=linux-centos8-x86_64_v3
        ^pixman@0.40.0%gcc@12.1.0 arch=linux-centos8-x86_64_v3
    ^fribidi@1.0.12%gcc@12.1.0 arch=linux-centos8-x86_64_v3
    ^gobject-introspection@1.56.1%gcc@12.1.0 patches=6f90bb2,7700828 arch=linux-centos8-x86_64_v3
        ^bison@3.8.2%gcc@12.1.0 arch=linux-centos8-x86_64_v3
        ^flex@2.6.3%gcc@12.1.0+lex~nls arch=linux-centos8-x86_64_v3
            ^findutils@4.9.0%gcc@12.1.0 patches=440b954 arch=linux-centos8-x86_64_v3
    ^harfbuzz@4.2.1%gcc@12.1.0~graphite2~strip buildtype=debugoptimized default_library=shared arch=linux-centos8-x86_64_v3
        ^icu4c@67.1%gcc@12.1.0 cxxstd=11 arch=linux-centos8-x86_64_v3
    ^json-glib@1.6.6%gcc@12.1.0~strip buildtype=debugoptimized default_library=shared arch=linux-centos8-x86_64_v3
    ^libxft@2.3.2%gcc@12.1.0 arch=linux-centos8-x86_64_v3
```

### Error message

<details><summary>Error message</summary><pre>
FAILED: pango/Pango-1.0.gir
...
Couldn't find include 'HarfBuzz-0.0.gir' (search path: '['$SPACK/opt/spack/linux-centos8-x86_64_v3/gcc-12.1.0/gobject-introspection-1.56.1-rnguct4wu7kil5shigcwel3w6wta3y3w/share/gir-1.0', '$SPACK/opt/spack/linux-centos8-x86_64_v3/gcc-12.1.0/gobject-introspection-1.56.1-rnguct4wu7kil5shigcwel3w6wta3y3w/share/gir-1.0', '$SPACK/opt/spack/linux-centos8-x86_64_v3/gcc-12.1.0/gobject-introspection-1.56.1-rnguct4wu7kil5shigcwel3w6wta3y3w/share/gir-1.0', '/usr/share/gir-1.0', '$SPACK/opt/spack/linux-centos8-x86_64_v3/gcc-12.1.0/gobject-introspection-1.56.1-rnguct4wu7kil5shigcwel3w6wta3y3w/share/gir-1.0']')
</pre></details>

### Information on your system

* **Spack:** 0.18.0.dev0 (d7d0c892d8e33ed0157140a28ef3e14c5bfe6577)
* **Python:** 3.6.8
* **Platform:** linux-centos8-x86_64_v3
* **Concretizer:** clingo

### Additional information

Looks like this was caused by #30591 (cc @wdconinc)

The system in question does not have a `HarfBuzz-0.0.gir` file anywhere (neither in Spack's tree nor in `/usr`), while my desktop has one in `/usr/lib64/girepository-1.0`.

### General information

- [X] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [X] I have run `spack maintainers <name-of-the-package>` and **@mentioned** any maintainers
- [X] I have uploaded the build log and environment files
- [X] I have searched the issues of this repo and believe this is not a duplicate


Discussion:
Thanks for reporting this.

This seems like the same problem I referred to here, https://github.com/spack/spack/pull/30591#issuecomment-1123049388. I had this during development of #30591 but it went away again before I could figure out what caused it. After that I was not able to reproduce it.

I suspect this is due to some local system configuration. It think the existence of such a file in `/usr/lib64/girepository-1.0` may be the crucial hint. My system seems I have that file installed as well.

While we work on a better solution, here are some workaround ideas:
- install systemwide libharbuzz-dev (not ideal, probably no admin privileges or you would have done so and reported that).
- enable introspection explicitly in harfbuzz, in `harfbuzz/package.py`  in `meson_args`:
```python
    # add the following
    depends_on('gobject-introspection')

    def meson_args(self):
        # add the following
        args.append('-Dintrospection=enabled')
```
- disable introspection explicitly in pango, in `pango/package.py`  in `meson_args`:
```python
    def meson_args(self):
        # add the following
        args.append('-Dintrospection=disabled')
```
(Note to self: the 'introspection' option in pango was called 'gir' until 1.43.0.)
Is there any reason not to enable it in harfbuzz? gtkplus also seems to have it enabled.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/harfbuzz/package.py b/var/spack/repos/builtin/packages/harfbuzz/package.py
--- a/var/spack/repos/builtin/packages/harfbuzz/package.py
+++ b/var/spack/repos/builtin/packages/harfbuzz/package.py
@@ -31,6 +31,7 @@ class Harfbuzz(MesonPackage):
 
     depends_on("pkgconfig", type="build")
     depends_on("glib")
+    depends_on("gobject-introspection")
     depends_on("icu4c")
     depends_on("freetype")
     depends_on("cairo+pdf+ft")
@@ -58,6 +59,20 @@ def flag_handler(self, name, flags):
                 flags.append('-std=gnu99')
         return (None, None, flags)
 
+    def setup_run_environment(self, env):
+        env.prepend_path("GI_TYPELIB_PATH",
+                         join_path(self.prefix.lib, 'girepository-1.0'))
+
+    def setup_dependent_build_environment(self, env, dependent_spec):
+        env.prepend_path('XDG_DATA_DIRS', self.prefix.share)
+        env.prepend_path("GI_TYPELIB_PATH",
+                         join_path(self.prefix.lib, 'girepository-1.0'))
+
+    def setup_dependent_run_environment(self, env, dependent_spec):
+        env.prepend_path('XDG_DATA_DIRS', self.prefix.share)
+        env.prepend_path("GI_TYPELIB_PATH",
+                         join_path(self.prefix.lib, 'girepository-1.0'))
+
     def meson_args(self):
         args = []
 


Test patch: