为什么大多数 R 包安装都会导致“非零退出状态”错误?

问题描述 投票:0回答:1

我在 R 中安装某些软件包时遇到了问题。每当我尝试安装 devtools、ggraph 或 igraph 等软件包时,我总是收到一条错误消息,指出:“安装软件包‘devtools’的退出状态为非零”。这个问题在多个软件包安装中仍然存在。

此外,值得注意的是,我需要专门的开发工具来安装一个名为 MuxVizR 的库。

有人可以提供如何解决此问题的指导吗?任何帮助将不胜感激。谢谢你。

举例来说:

install.packages("ggraph"), 
result into 
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() 的输出

> 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
r igraph devtools ggraph
1个回答
0
投票

如果您使用二进制文件(Ubuntu 存在),则不会有这个问题!请参阅

r2u
网站,其中包含 22,000 个用于 jammy(和 focus)的 CRAN 二进制文件:https://eddelbuettel.github.io/r2u

更好的是,借助

bspm
包,您可以从 R 中访问这些内容。因此,在启用了
r2u
rocker/r2u 容器的机器上,我可以这样做

$ time Rscript -e 'install.packages("ggraph")

13.5 秒后,我总共安装了 53 个(!!!)二进制包,其中包括

ggraph
的大约两到三打 CRAN 依赖项。

© www.soinside.com 2019 - 2024. All rights reserved.