如何将兼容版本的 devtools 安装到 R 3.5.1?

How do I install a compatible version of devtools to R 3.5.1?

目标

我想将 devtools 安装到我的 R 版本 3.5.1。

问题

当我安装包 devtools 时,出现以下错误:


here are binary versions available but the source versions are later:
         binary source needs_compilation
processx  3.4.2  3.4.5              TRUE
callr     3.4.3  3.5.1             FALSE
covr      3.5.0  3.5.1              TRUE
ellipsis  0.3.0  0.3.1              TRUE
jsonlite  1.6.1  1.7.2              TRUE
pkgbuild  1.0.6  1.2.0             FALSE
pkgload   1.0.2  1.1.0              TRUE
rlang     0.4.5 0.4.10              TRUE
roxygen2  7.1.0  7.1.1              TRUE
devtools  2.3.0  2.3.2             FALSE


....
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : 
  namespace 'processx' 3.4.2 is being loaded, but >= 3.4.4 is required

ERROR: lazy loading failed for package 'callr'
* removing 'C:/Users/User/AppData/Local/R/win-library/3.5/callr'
In R CMD INSTALL
Warning in install.packages :
  installation of package ‘callr’ had non-zero exit status

ERROR: dependency 'callr' is not available for package 'pkgbuild'
* removing 'C:/Users/User/AppData/Local/R/win-library/3.5/pkgbuild'
In R CMD INSTALL
Warning in install.packages :
  installation of package ‘pkgbuild’ had non-zero exit status

ERROR: dependencies 'callr', 'pkgbuild' are not available for package 'devtools'
* removing 'C:/Users/User/AppData/Local/R/win-library/3.5/devtools'
In R CMD INSTALL
Warning in install.packages :
  installation of package ‘devtools’ had non-zero exit status

尝试的解决方案

我尝试直接安装 processx 3.4.2,方法是将软件包从 https://github.com/r-lib/processx/releases/tag/v3.4.2 下载到我的库中。

install.packages(paste0(folder, "processx-3.4.2.tar.gz"), repos = NULL)

然而,我收到以下错误消息:

Warning in untar2(tarfile, files, list, exdir, restore_times) :
  failed to copy 'processx-3.4.2/inst/CODE_OF_CONDUCT.md' to 'processx-3.4.2/CODE_OF_CONDUCT.md'
Warning in untar2(tarfile, files, list, exdir, restore_times) :
  skipping pax global extended headers
* installing *source* package 'processx' ...
** libs

*** arch - i386
Warning in system(cmd) : 'make' not found
ERROR: compilation failed for package 'processx'
* removing 'C:/Users/User/AppData/Local/R/win-library/3.5/processx'
In R CMD INSTALL
Warning in install.packages :
  installation of package ‘C:/Users/User/AppData/Local/R/win-library/3.5/processx-3.4.2.tar.gz’ had non-zero exit status

最简单的解决方法是:

  1. 安装更新版本的R(!!推荐!!)
  2. 使用快照镜像,例如 Microsoft 在 https://mran.microsoft.com/snapshots/{date} (replacing {date}) as the mirror argument in install.packages. By looking at https://cran.r-project.org/bin/windows/base/old/ 提供的快照镜像,我们可以看到 R-3.5.1 替换为 R-3.5.2 2018 年 12 月。所以我建议使用 2018-11-31 作为您的快照镜像。
install.packages('devtools', mirror = 'https://mran.microsoft.com/snapshots/2018-11-31')

一些已安装的软件包可能会“搞砸安装”(太新的版本?)所以如果安装或某些代码在安装后失败,我建议使用 renvR projects(在 Rstudio 中).这将确保所有软件包都安装在全新环境中,并且 应该 没有版本冲突(因为它们都将从特定快照安装)。阅读 renv 的介绍指南和 Rstudio 对项目的支持可以帮助解决这个问题(如果您发现更多问题)。
卸载软件包也可能就足够了(但它可能会破坏其他一些依赖项)。