简体   繁体   English

防止 R 自动获取已安装软件包的最新版本?

[英]Keep R from automatically grabbing latest version of already installed package?

I'm trying to install R package A into a Singularity container with R 3.6.0.我正在尝试使用 R 3.6.0 将 R 包 A 安装到 Singularity 容器中。 Package A needs R package B as a dependency.包 A 需要 R 包 B 作为依赖项。 I originally installed package A with version 1 of package B, and things worked fine.我最初将包 A 与包 B 的版本 1 一起安装,并且一切正常。 Now, however, I need to rebuild this setup, and it appears that version 2 of package B has come out.然而,现在我需要重新构建这个设置,看起来包 B 的版本 2 已经出来了。 For some reason, package B version 2 doesn't build on my machine, and gives random compiler errors that I can't find any reference to online.出于某种原因,包 B 版本 2 没有在我的机器上构建,并给出了我在网上找不到任何参考的随机编译器错误。 I can still install version 1 of package B no problem.我仍然可以安装包 B 的版本 1 没问题。 However, when I try to install package A, it pulls version 2 of package B from CRAN, even though the correct version (version 1) of package B is already installed, thus making the whole thing not work as version 2 of package B fails to build.但是,当我尝试安装包 A 时,它会从 CRAN 中提取包 B 的版本 2,即使已经安装了包 B 的正确版本(版本 1),从而使整个过程无法正常工作,因为包 B 的版本 2 失败建立。

How can I tell R to not grab the latest version of package B, and to just use the one already installed?我如何告诉 R 不要获取包 B 的最新版本,而只使用已经安装的版本? This is on CentOS 7 building inside of a Singularity container.这是在 Singularity 容器内的 CentOS 7 构建上。 I'm using the standard "install.packages" function to install package A, and the "install_version" command from devtools to install the specific version of package B. I want to stress that package A is still being installed as the same version, and that the entire issue here stems from R pulling the version 2 of package B, even though the same version of package A originally worked fine with version 1 of package B.我正在使用标准的“install.packages”函数来安装包 A,并使用 devtools 中的“install_version”命令来安装包 B 的特定版本。我想强调的是,包 A 仍然作为相同版本安装,并且这里的整个问题源于 R 拉取包 B 的版本 2,即使包 A 的相同版本最初与包 B 的版本 1 一起工作正常。

I would:我会:

  1. Install the older version of package B using install_version使用install_version安装包 B 的旧版本
  2. Install the new package without dependencies using install.packages("A", dependencies=FALSE)使用install.packages("A", dependencies=FALSE)安装没有依赖项的新包

The easiest way is to use packages in versions that worked for you before.最简单的方法是在以前适合您的版本中使用包。 For that find out the date when it worked at put into repo url.为此,找出它在放入 repo url 时工作的日期。

install.packages(
  "A",
  repos="https://cran.microsoft.com/snapshot/2019-05-15/"
)

Before running that command ensure that B is removed.在运行该命令之前,请确保删除 B。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM