【问题标题】:R - New libraries fail to install even though dependencies are thereR - 即使存在依赖项,新库也无法安装
【发布时间】:2022-08-24 19:55:34
【问题描述】:

我有一个相当有趣的问题,我找不到答案。我正在使用 RStudio Server (v. 1.4.1717),并且安装了 R 版本 4.1.0。我尝试将 Projects 与 renv 一起使用,到目前为止它还不错,即使我在偶尔安装库时遇到问题。

但是,现在我不断收到此错误: Error: package ‘xxx’ required by ‘yyy’ could not be found

我已经尝试了几件事。我尝试将.libPaths() 更改为新位置,重新安装每个库,但这并没有解决我的问题。我也尝试在项目内部和外部执行此操作(因此,renv 也处于活动状态和禁用状态),但我一直遇到同样的问题。举个例子:

>BiocManager::install(\"MatrixGenerics\", lib = \"/media/erkin/lib\")
getOption(\"repos\")\' replaces Bioconductor standard repositories, see \'?repositories\' for details

replacement repositories:
    CRAN: https://packagemanager.rstudio.com/all/__linux__/focal/latest

Bioconductor version 3.14 (BiocManager 1.30.18), R 4.1.0 (2021-05-18)
Installing package(s) \'MatrixGenerics\'
trying URL \'https://bioconductor.org/packages/3.14/bioc/src/contrib/MatrixGenerics_1.6.0.tar.gz\'
Content type \'application/x-gzip\' length 28270 bytes (27 KB)
==================================================
downloaded 27 KB

* installing *source* package ‘MatrixGenerics’ ...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error: package ‘matrixStats’ required by ‘MatrixGenerics’ could not be found
Execution halted
ERROR: lazy loading failed for package ‘MatrixGenerics’
* removing ‘/media/erkin/lib/MatrixGenerics’

The downloaded source packages are in
    ‘/tmp/RtmpgabWCB/downloaded_packages’
Warning message:
In install.packages(...) :
  installation of package ‘MatrixGenerics’ had non-zero exit status

我已经安装了matrixStats,我可以调用它。如果我检查sessionInfo()

Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.2 LTS

Matrix products: default
BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=C              LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] matrixStats_0.62.0  BiocGenerics_0.40.0

loaded via a namespace (and not attached):
[1] BiocManager_1.30.18 compiler_4.1.0      tools_4.1.0  

这不是唯一发生这种情况的包。我尝试安装的许多其他软件包(例如S4Vectors 安装找不到BiocGenericsBiocStyle 安装说没有名为BiocManager 的软件包)只是一直失败。

我可能遗漏了一些东西,有人知道为什么我的 R 无法找到已安装的软件包来安装新软件包吗?

  • find.package(\"matrixStats\") 的输出是什么?它是偶然安装到单独的库路径中的吗?
  • 非常感谢您的回复@KevinUshey,我现在已经通过安装 tidyverse 和 dplyr 及其依赖项解决了这个问题......我不确定这是如何相关的,以及它如何解决找不到已经存在的库的问题安装,但不知何故它现在工作。我将尝试重新创建问题,看看find.package() 是否给我提供了与预期不同的输出。
  • 我设法通过使用新的 renv 库以及干净的基础库(我的意思是,renv 之前的默认库路径没有用户安装的库)来重新创建问题。这是find.package(\"matrixStats\") 的输出:> find.package(\"matrixStats\") [1] \"/home/ilacar/test_project/library_test/renv/library/R-4.1/x86_64-pc-linux-gnu/matrixStats\" > .libPaths() [1] \"/home/ilacar/test_project/library_test/renv/library/R-4.1/x86_64-pc-linux-gnu\" [2] \"/usr/local/lib/R/library\"

标签: r failed-installation r-library


【解决方案1】:

我通过删除 .Rprofile 解决了这个问题。

如果你有一个 .Rprofile 文件并且在那里设置了库,那么使用 renv 会“混淆”主库路径。我认为它最终会检查 .Rprofile 显示的路径,即使所有其他命令(.libPaths()find.package())显示 renv 库路径。删除 .Rprofile 为我解决了所有问题。

【讨论】:

    猜你喜欢
    • 2020-10-30
    • 2018-03-17
    • 1970-01-01
    • 1970-01-01
    • 2019-07-03
    • 2023-03-09
    • 1970-01-01
    • 2016-02-06
    • 2020-05-26
    相关资源
    最近更新 更多