4
votes

I'm having an issue installing Flextable, and it seems to be because of the gdtools package. It looks like gdtools relies on a .dylib file? Any ideas?

> install.packages("flextable")

  There is a binary version available but the source version is later:
          binary source needs_compilation
flextable  0.4.0  0.4.2             FALSE

installing the source package ‘flextable’

trying URL 'https://cran.rstudio.com/src/contrib/flextable_0.4.2.tar.gz'
Content type 'application/x-gzip' length 135276 bytes (132 KB)
==================================================
downloaded 132 KB

Warning in strptime(xx, f <- "%Y-%m-%d %H:%M:%OS", tz = tz) :
  unknown timezone 'default/Australia/Melbourne'
* installing *source* package ‘flextable’ ...
** package ‘flextable’ successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/Library/Frameworks/R.framework/Versions/3.4/Resources/library/gdtools/libs/gdtools.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/gdtools/libs/gdtools.so, 6): Library not loaded: /opt/X11/lib/libcairo.2.dylib
  Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/gdtools/libs/gdtools.so
  Reason: image not found
ERROR: lazy loading failed for package ‘flextable’
* removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/flextable’
Warning in install.packages :
  installation of package ‘flextable’ had non-zero exit status

The downloaded source packages are in
    ‘/private/var/folders/fs/2zzbjym545vgl0hvq4pvs6sc0000gn/T/Rtmpdo3FMp/downloaded_packages’
3
Try install.packages("flextable", type = "binary"), your system may not be set up to install packages from source.Marius
Thanks for the sarcasm 42 - really helpful. Marius - that didn't work either. I still get the same error. But thank you.LucaS

3 Answers

9
votes

I managed to solve this by reinstalling quartz: https://www.xquartz.org

5
votes

For mac users. This is sometimes happening with mac os X updates. This requires Homebrew(it can be installed with the following command:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  1. Close all R sessions (not mandatory but from experience, it's the best solution).

In a terminal, run the following commands:

brew update
brew upgrade
brew reinstall cairo
  1. Open an R session and run the following code:

    install.packages("gdtools", type = "source")

0
votes

I'll try to help, even if I don't know your O.S. Mine is Ubuntu 20.10, I solved it as follows (This solution works for Debian, Ubuntu, etc.):

In the terminal type: sudo apt-get install libfontconfig1-dev

Then: sudo apt-get install libcairo2-dev

In the R console type:

install.packages("flextable")

library(flextable)

Other distros, install according to your distro:

Step 1

  • deb: libfontconfig1-dev (Debian, Ubuntu, etc.)
  • rpm: fontconfig-devel (Fedora, EPEL)
  • csw: fontconfig_dev (Solaris)
  • brew: freetype (OSX)

Step 2

  • deb: libcairo2-dev (Debian, Ubuntu)
  • rpm: cairo-devel (Fedora, CentOS, RHEL)
  • csw: libcairo_dev (Solaris)
  • brew: cairo (OSX)