Search code examples
rdevtools

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


Goal

I would like to install devtools to my version of R version 3.5.1.

Problem

When I install the package devtools, I get the following error:


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

Attempted Solution

I tried to install processx 3.4.2 directly by downloading the package into my library from https://github.com/r-lib/processx/releases/tag/v3.4.2.

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

Yet, I got the following error message:

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


Solution

  • Your simplest fix is to either:

    1. Install a newer version of R (!!recommended!!)
    2. Use a snapshot mirror such as the ones from provided by microsoft at 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/ we can see that R-3.5.1 was replaced by R-3.5.2 in december 2018. So I would suggest using 2018-11-31 as your snapshot mirror.
    install.packages('devtools', mirror = 'https://mran.microsoft.com/snapshots/2018-11-31')
    

    Some installed packages might "screw up the installation" (too recent versions?) so if the installation or some code fails after installation, I would suggest using renv and R projects (in Rstudio). This would ensure all packages are installed in a fresh environment and that there should be no version conflict (as they will all be installed from the specific snapshot). Reading introduction guides for renv and the Rstudio support for projects can help with this (in case you observe further problems).
    It might also be sufficient to uninstall the packages (but it might break some other dependencies).