rloadingkableextrainstallation-package

Can't Load kableExtra After Installation


I apologize in advance if I could've formatted this better - I am new to Stack Overflow. I am trying to install the kableExtra package. While I'm able to install it, I keep getting this error message when trying to load the package. How exactly can I fix this?

install.packages("kableExtra", dependencies = TRUE)
library(kableExtra)
Error: package or namespace load failed for ‘kableExtra’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Users/tirdodbehbehani/Library/R/3.6/library/systemfonts/libs/systemfonts.so':
  dlopen(/Users/tirdodbehbehani/Library/R/3.6/library/systemfonts/libs/systemfonts.so, 6): Library not loaded: /opt/X11/lib/libfreetype.6.dylib
  Referenced from: /Users/tirdodbehbehani/Library/R/3.6/library/systemfonts/libs/systemfonts.so
  Reason: image not found
In addition: Warning message:
package ‘kableExtra’ was built under R version 3.6.2 
sessionInfo()

R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.7

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rlang_0.4.11 hms_1.1.0   

loaded via a namespace (and not attached):
 [1] pillar_1.6.1      compiler_3.6.1    tools_3.6.1       digest_0.6.27    
 [5] evaluate_0.14     lifecycle_1.0.0   tibble_3.1.2      pkgconfig_2.0.3  
 [9] DBI_1.1.1         rstudioapi_0.13   yaml_2.2.1        xfun_0.24        
[13] dplyr_1.0.6       httr_1.4.2        stringr_1.4.0     knitr_1.33       
[17] xml2_1.3.2        generics_0.1.0    vctrs_0.3.8       tidyselect_1.1.1 
[21] glue_1.4.2        R6_2.5.0          fansi_0.5.0       rmarkdown_2.9.1  
[25] purrr_0.3.4       magrittr_2.0.1    scales_1.1.1      ellipsis_0.3.2   
[29] htmltools_0.5.1.1 assertthat_0.2.1  rvest_1.0.0       colorspace_2.0-2 
[33] utf8_1.2.1        stringi_1.6.2     munsell_0.5.0     crayon_1.4.1

Solution

  • You appear to have a broken copy of the systemfonts package. You could try reinstalling it before installing kableExtra, but it might fail to install, because you also appear to be missing the /opt/X11/lib/libfreetype.6.dylib dynamic library. You may need to install that: but I can't suggest how to do that without knowing more about your system.

    You edited your question to include the result of running sessionInfo(); thanks! What that tells me is that you're running on a Mac: so you would install XQuartz to get the X11 libs. I think that should get you libfreetype.

    I also see that you are running R version 3.6.1. That's 2 years old, and current packages may not be available for it. It's generally a good idea to stay current, and R 4.1.0 was recently released, so I'd suggest updating to that version. Before you update, run pkgnames <- rownames(installed.packages(priority = "NA")); dput(pkgnames) and save the results to a file. Then update R, and run

    pkgnames <- [ the long string you saved ]
    install.packages(pkgnames)
    

    to install the latest versions of any contributed packages you were using.