无法在新的 Ubuntu 设备上安装 R 软件包

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

我是一名医生(所以根本没有计算机科学背景),开始涉足大数据集的生物信息学分析,并且过去在我的私人 Windows 笔记本电脑上使用 R 没有任何问题。

我的部门现在购买了一台功能强大的新笔记本电脑来加快分析速度,我们的生物信息学核心设施建议使用 Linux 系统(我以前从未真正使用过),所以现在我有了这台很棒的 Ubuntu 笔记本电脑,但我有点沮丧只需设置我的 R 环境即可开始工作。我听说 Linux 需要一些时间来适应,我已经做好迎接挑战的准备,并想尝试了解我在做什么。

所以我遇到的问题是我无法真正在 R 中安装某些软件包。正如我所说,笔记本电脑是全新的,安装 R 和 RStudio 是我在不更改笔记本电脑基本设置中任何内容的情况下所做的第一件事。所以我很惊讶我在安装这些软件包这样简单的事情上不断遇到错误。由于某种原因,有些软件包像

install.packages("tidyverse")

工作正常,而其他人则失败。所以

install.packages("devtools")

给我以下输出

Installing package into ‘/home/jasper/R/x86_64-pc-linux-gnu-library/4.2’
(as ‘lib’ is unspecified)
also installing the dependencies ‘systemfonts’, ‘textshaping’, ‘ragg’, ‘pkgdown’

trying URL 'https://cloud.r-project.org/src/contrib/systemfonts_1.0.4.tar.gz'
Content type 'application/x-gzip' length 81757 bytes (79 KB)
==================================================
downloaded 79 KB

trying URL 'https://cloud.r-project.org/src/contrib/textshaping_0.3.6.tar.gz'
Content type 'application/x-gzip' length 35722 bytes (34 KB)
==================================================
downloaded 34 KB

trying URL 'https://cloud.r-project.org/src/contrib/ragg_1.2.4.tar.gz'
Content type 'application/x-gzip' length 427579 bytes (417 KB)
==================================================
downloaded 417 KB

trying URL 'https://cloud.r-project.org/src/contrib/pkgdown_2.0.7.tar.gz'
Content type 'application/x-gzip' length 871465 bytes (851 KB)
==================================================
downloaded 851 KB

trying URL 'https://cloud.r-project.org/src/contrib/devtools_2.4.5.tar.gz'
Content type 'application/x-gzip' length 374718 bytes (365 KB)
==================================================
downloaded 365 KB

* installing *source* package ‘systemfonts’ ...
** package ‘systemfonts’ successfully unpacked and MD5 sums checked
** using staged installation
Package fontconfig was not found in the pkg-config search path.
Perhaps you should add the directory containing `fontconfig.pc'
to the PKG_CONFIG_PATH environment variable
No package 'fontconfig' found
Package freetype2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `freetype2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'freetype2' found
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/jasper/R/x86_64-pc-linux-gnu-library/4.2/systemfonts’
Warning in install.packages :
  installation of package ‘systemfonts’ had non-zero exit status
ERROR: dependency ‘systemfonts’ is not available for package ‘textshaping’
* removing ‘/home/jasper/R/x86_64-pc-linux-gnu-library/4.2/textshaping’
Warning in install.packages :
  installation of package ‘textshaping’ had non-zero exit status
ERROR: dependencies ‘systemfonts’, ‘textshaping’ are not available for package ‘ragg’
* removing ‘/home/jasper/R/x86_64-pc-linux-gnu-library/4.2/ragg’
Warning in install.packages :
  installation of package ‘ragg’ had non-zero exit status
ERROR: dependency ‘ragg’ is not available for package ‘pkgdown’
* removing ‘/home/jasper/R/x86_64-pc-linux-gnu-library/4.2/pkgdown’
Warning in install.packages :
  installation of package ‘pkgdown’ had non-zero exit status
ERROR: dependency ‘pkgdown’ is not available for package ‘devtools’
* removing ‘/home/jasper/R/x86_64-pc-linux-gnu-library/4.2/devtools’
Warning in install.packages :
  installation of package ‘devtools’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/RtmpZcPwU9/downloaded_packages’

在网上查了几天后,我认为目录或访问权限有问题。当我进来的时候

.libPaths()

在 R 中,它给了我

[1]“/home/jasper/R/x86_64-pc-linux-gnu-library/4.2”“/usr/local/lib/R/site-library”
[3]“/usr/lib/R/site-library”“/usr/lib/R/library”

所以我开始研究这个问题,并尝试按照此处所述修改 Renviron 文件的 R_LIBS_USER 部分(如何更改 R 包的默认库路径),但没有成功。

当我尝试安装另一个软件包时,我收到消息称该路径不可写,我读到这可能是权限问题。因此,我在 .libPaths() 显示的四个目录(据我所知,这给了我对这些文件夹的所有权限)上使用了 chmod -R 777 ,但也没有成功。反复重新安装 R 和 RStudio 也没有帮助。

不幸的是,我的计算机科学技能很快就达到了极限(说实话,即使是使用终端)。由于我真的不明白我在做什么,并且想在更改这台新笔记本电脑根目录中的文件时这样做,我希望你能帮助我。退出并改回 Windows 对我来说不是一个选择 :D .

这是我的 sessionInfo():

R版本4.2.2已修补(2022-11-10 r83330) 平台:x86_64-pc-linux-gnu(64位) 运行环境:Ubuntu 20.04.5 LTS

矩阵产品:默认 BLAS:/usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 LAPACK:/usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

区域设置: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=de_DE.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=de_DE.UTF-8
[6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=de_DE.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C

附加基础包: [1] 统计图形 grDevices utils 数据集方法基础

通过命名空间加载(且未附加): [1] 编译器_4.2.2 fastmap_1.1.0 cli_3.4.1 htmltools_0.5.4 工具_4.2.2 rstudioapi_0.14 yaml_2.3.6 rmarkdown_2.19 [9]knitr_1.41 xfun_0.35digest_0.6.31rlang_1.0.6evaluate_0.19

我非常感谢您的帮助!

非常感谢,

贾斯珀

r ubuntu directory bioinformatics devtools
2个回答
3
投票

我最近在尝试在 kali linux 虚拟机上安装 devtools 时遇到了同样的问题。

我解决这个问题的方法是直接从 Linux 命令行(终端)安装开发工具:

sudo apt-get install r-cran-devtools

这也应该适用于 Ubuntu。祝你好运。


0
投票

为未来的 freetype2 受害者添加另一个解决方法。每次在 Ubuntu 上升级 R 时都会遇到这个问题。这次我设置了 RStudio Package Manager,并且像做梦一样安装了 systemfonts。设置非常简单,您甚至可以与 renv 一起使用。
https://packagemanager.posit.co/client/#/repos/cran/setup

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