R包安装频繁报‘non-zero exit status’错误的解决求助
解决R包安装(devtools/ggraph/igraph等)的非零退出状态问题
问题概述
安装devtools、ggraph、igraph等R包时,反复出现“installation of package ‘xxx’ had non-zero exit status”错误,需通过devtools安装MuxVizR,求解决方法。
安装ggraph时的错误提示
install.packages("ggraph") # 输出结果: The downloaded source packages are in ‘/tmp/RtmpUNOHvP/downloaded_packages’ Warning messages: 1: In install.packages("ggraph") : installation of package ‘systemfonts’ had non-zero exit status 2: In install.packages("ggraph") : installation of package ‘RcppEigen’ had non-zero exit status 3: In install.packages("ggraph") : installation of package ‘RcppArmadillo’ had non-zero exit status 4: In install.packages("ggraph") : installation of package ‘igraph’ had non-zero exit status 5: In install.packages("ggraph") : installation of package ‘ggforce’ had non-zero exit status 6: In install.packages("ggraph") : installation of package ‘tidygraph’ had non-zero exit status 7: In install.packages("ggraph") : installation of package ‘graphlayouts’ had non-zero exit status 8: In install.packages("ggraph") : installation of package ‘ggraph’ had non-zero exit status
系统环境信息
> sessionInfo() R version 4.3.3 (2024-02-29) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 22.04.4 LTS Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0 locale: [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C time zone: Europe/Rome tzcode source: system (glibc) attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.3.3 tools_4.3.3
详细安装日志(前半部分)
install.packages("ggraph") Installing package into ‘/home/alessio/R/x86_64-pc-linux-gnu-library/4.3’ (as ‘lib’ is unspecified) also installing the dependencies ‘systemfonts’, ‘RcppEigen’, ‘RcppArmadillo’, ‘ggforce’, ‘igraph’, ‘tidygraph’, ‘graphlayouts’ trying URL 'https://cloud.r-project.org/src/contrib/systemfonts_1.0.6.tar.gz' Content type 'application/x-gzip' length 80844 bytes (78 KB) ================================================== downloaded 78 KB trying URL 'https://cloud.r-project.org/src/contrib/RcppEigen_0.3.4.0.0.tar.gz' Content type 'application/x-gzip' length 1765714 bytes (1.7 MB) ================================================== downloaded 1.7 MB trying URL 'https://cloud.r-project.org/src/contrib/RcppArmadillo_0.12.8.1.0.tar.gz' Content type 'application/x-gzip' length 1404885 bytes (1.3 MB) ================================================== downloaded 1.3 MB trying URL 'https://cloud.r-project.org/src/contrib/ggforce_0.4.2.tar.gz' Content type 'application/x-gzip' length 866255 bytes (845 KB) ================================================== downloaded 845 KB trying URL 'https://cloud.r-project.org/src/contrib/igraph_2.0.3.tar.gz' Content type 'application/x-gzip' length 4967875 bytes (4.7 MB) ================================================== downloaded 4.7 MB trying URL 'https://cloud.r-project.org/src/contrib/tidygraph_1.3.1.tar.gz' Content type 'application/x-gzip' length 133606 bytes (130 KB) ================================================== downloaded 130 KB trying URL 'https://cloud.r-project.org/src/contrib/graphlayouts_1.1.1.tar.gz' Content type 'application/x-gzip' length 3827271 bytes (3.6 MB) ================================================== downloaded 3.6 MB trying URL 'https://cloud.r-project.org/src/contrib/ggraph_2.2.1.tar.gz' Content type 'application/x-gzip' length 3443217 bytes (3.3 MB) ================================================== downloaded 3.3 MB * installing *source* package ‘systemfonts’ ... ** package ‘systemfonts’ successfully unpacked and MD5 sums checked ** using staged installation Using PKG_CFLAGS= Using PKG_LIBS=-lfontconfig -lfreetype --------------------------- [ANTICONF] -------------------------------- Configuration failed to find the fontconfig freetype2 library. Try installing: * deb: libfontconfig1-dev (Debian, Ubuntu, etc) * rpm: fontconfig-devel (Fedora, EPEL) * csw: fontconfig_dev (Solaris) * brew: freetype (OSX) If fontconfig freetype2 is already installed, check that 'pkg-config' is in your PATH and PKG_CONFIG_PATH contains a fontconfig freetype2.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] --------------------------- <stdin>:1:10: fatal error: fontconfig/fontconfig.h: No such file or directory compilation terminated. -------------------------------------------------------------------- ERROR: configuration failed for package ‘systemfonts’ * removing ‘/home/alessio/R/x86_64-pc-linux-gnu-library/4.3/systemfonts’ * installing *source* package ‘RcppEigen’ ... ** package ‘RcppEigen’ successfully unpacked and MD5 sums checked ** using staged installation ** libs using C++ compiler: ‘g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ g++ -std=gnu++17 -I"/usr/share/R/include" -DNDEBUG -I'/home/alessio/R/x86_64-pc-linux-gnu-library/4.3/Rcpp/include' -I../inst/include -fpic -g -O2 -ffile-prefix-map=/build/r-base-14Q6vq/r-base-4.3.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c RcppEigen.cpp -o RcppEigen.o
解决方案
1. 安装系统依赖库
从日志可见,核心问题是缺少fontconfig和freetype的开发库,在Ubuntu 22.04下执行:
sudo apt update && sudo apt install -y libfontconfig1-dev libfreetype6-dev pkg-config
2. 补充编译环境依赖
针对RcppEigen、RcppArmadillo等编译型包,需确保C++编译环境完整:
sudo apt install -y r-base-dev build-essential libblas-dev liblapack-dev
3. 重新安装R包
先修复依赖后安装systemfonts,再安装目标包:
install.packages("systemfonts") install.packages(c("devtools", "ggraph", "igraph"))
4. 安装MuxVizR
devtools安装成功后,执行:
devtools::install_github("manlius/muxVizR")
内容的提问来源于stack exchange,提问作者TimeassassinRG
相关产品推荐
相关产品推荐

