0

I'm working on this code, and when I try to knit analyses.Rmd on one of my computers, I get an error specifically due to the attempt to load kableExtra:

Error: package or namespace load failed for ‘kableExtra’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object '/Users/acristia/Library/Application Support/renv/cache/v5/R-4.1/x86_64-apple-darwin17.0/systemfonts/1.0.3/5be9fcf8ef6763e8cb13ab009e273a1d/systemfonts/libs/systemfonts.so': dlopen(/Users/acristia/Library/Application Support/renv/cache/v5/R-4.1/x86_64-apple-darwin17.0/systemfonts/1.0.3/5be9fcf8ef6763e8cb13ab009e273a1d/systemfonts/libs/systemfonts.so, 0x0006): Library not loaded: /usr/local/opt/freetype/lib/libfreetype.6.dylib Referenced from: /Users/acristia/Library/Application Support/renv/cache/v5/R-4.1/x86_64-apple-darwin17.0/systemfonts/1.0.3/5be9fcf8ef6763e8cb13ab009e273a1d/systemfonts/libs/systemfonts.so Reason: tried: '/usr/local/opt/freetype/lib/libfreetype.6.dylib' (no such file), '/Library/Frameworks/R.framework/Resources/lib/libfreetype.6.dylib' (no such file), '/Users/acristia/lib/libfreetype.6.dylib' (no such file), '/usr/local/lib/lib

I've checked that:

  • I have the latest version of R, and Rstudio
  • I have the latest version of freetype (also run brew doctor & fixed all warnings there)

Since brew was not installing libfreetype where kableExtra expected it, I did sudo mkdir -p /usr/local/opt/freetype/lib/ and sudo ln -s /opt/homebrew/lib/libfreetype.6.dylib /usr/local/opt/freetype/lib/libfreetype.6.dylib MacBook-Air:weirdChildes acristia$ ls /usr/local/opt/freetype/lib/libfreetype.6.dylib

With this, I changed the error from not loaded because it doesn't exist, to not loaded because of wrong architecture:

tried: '/usr/local/opt/freetype/lib/libfreetype.6.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')),

(I also saw a suggestion to do brew install freetype --universal but that command is not recognized.

For context: I migrated my mac account to a new laptop, which is intel / monterey, and this probably means that some basic files are not right.

Or potentially, the error arises because makers of kableExtra need to take into account this new architecture. I did find two open issues mentioning libfreetype in the kableExtra github (one saying the problem was resolved with the latest R version, which is not my case).

For full information on my system, see renv-diagnostics.txt

Phil
  • 7,287
  • 3
  • 36
  • 66
A Cristia
  • 31
  • 4
  • It sounds as though you are mixing Brew builds of libraries with CRAN builds. That often leads to incompatibilities. You should uninstall R and all packages, and reinstall them from CRAN. – user2554330 Jan 12 '22 at 10:20
  • [This](https://stackoverflow.com/a/68217304/5783745) may be related. (spoiler: it basically says what @user2554330 recommends, i.e. to reinstall everything) – stevec Jan 12 '22 at 11:05

2 Answers2

1

You have linked a copy of freetype from your old Apple Silicon homebrew directory, which is /opt/homebrew/lib

For Intel macs, the directory in which homebrew installs the freetype package is /usr/local/lib

Intel macs use the architecture x86_64

Apple Silicon (M1) uses the arm64 architecture.

Richard Barber
  • 5,257
  • 2
  • 15
  • 26
0

As suggested by Richard Barber, you could try to create a symbolic link for libfreetype.6.dylib in /usr/local/lib/ with

sudo ln -s /opt/homebrew/lib/libfreetype.6.dylib /usr/local/liblibfreetype.6.dylib

See related issue: https://stackoverflow.com/a/76903720/21565913.

layal
  • 180
  • 11