Installing tidyverse or Seurat in R gives an error with the textshaping package

When trying to install a large library of packages (such as Seurat or the tidyverse), one of the dependencies is the textshaping package. All of my installs fail when trying to install this package and I can’t use any of the libraries I need. The installation throws the following error:

  • installing source package ‘textshaping’ …
    ** package ‘textshaping’ successfully unpacked and MD5 sums checked
    ** using staged installation
    Package harfbuzz was not found in the pkg-config search path.
    Perhaps you should add the directory containing harfbuzz.pc' to the PKG_CONFIG_PATH environment variable No package 'harfbuzz' found Package fribidi was not found in the pkg-config search path. Perhaps you should add the directory containing fribidi.pc’
    to the PKG_CONFIG_PATH environment variable
    No package ‘fribidi’ found
    Using PKG_CFLAGS=
    Using PKG_LIBS=-lfreetype -lharfbuzz -lfribidi -lpng
    --------------------------- [ANTICONF] --------------------------------
    Configuration failed to find the harfbuzz freetype2 fribidi library. Try installing:
  • deb: libharfbuzz-dev libfribidi-dev (Debian, Ubuntu, etc)
  • rpm: harfbuzz-devel fribidi-devel (Fedora, EPEL)
  • csw: libharfbuzz_dev libfribidi_dev (Solaris)
  • brew: harfbuzz fribidi (OSX)
    If harfbuzz freetype2 fribidi is already installed, check that ‘pkg-config’ is in your
    PATH and PKG_CONFIG_PATH contains a harfbuzz freetype2 fribidi.pc file. If pkg-config
    is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
    R CMD INSTALL --configure-vars=‘INCLUDE_DIR=… LIB_DIR=…’
    -------------------------- [ERROR MESSAGE] ---------------------------
    :1:10: fatal error: hb-ft.h: No such file or directory
    compilation terminated.

ERROR: configuration failed for package ‘textshaping’

  • removing ‘/data/user/home/curtish/R/x86_64-pc-linux-gnu-library/4.2/textshaping’
    Warning in install.packages :
    installation of package ‘textshaping’ had non-zero exit status

How can I fix this issue?

The textshaping package requires the FriBidi and Harbuzz unix libraries that are not automatically loaded with our R modules, but both are available as individual modules on the cluster. To successfully install textshaping as well as the packages it is a dependency for, include the following lines in your Environment Setup window when requesting an RStudio job:

module load HarfBuzz
module load FriBidi

Try installing harfbuzz and reinstalling the textshaping package.