rrtools

Rtools not found by R when installing packages from CRAN


When install any new package I get errors saying Rtools is not found. I followed the manual install instructions for Rtools but still get the same error message.

> install.packages("phyloseq")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding

It seems R is not finding Rtools. Is there anyway to fix this?

I have noticed a second issue of previously installed packages disappearing also when starting new R sessions. Could these two issues be linked?

My R version in 4.0 and I am working in Windows 64bit


Solution

  • After installation is complete, you need to perform one more step to be able to compile R packages: you need to put the location of the Rtools make utilities (bash, make, etc) on the PATH. The easiest way to do so is create a text file .Renviron in your Documents folder which contains the following line:

    writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron")
    

    Now restart R, and verify that make can be found, which should show the path to your Rtools installation.

    Sys.which("make")
    ## "C:\\rtools40\\usr\\bin\\make.exe"
    

    https://cran.r-project.org/bin/windows/Rtools/

    The second part with packages not being found has to do with upgrading the R version e.g. 3.5 to 3.6 or 3.6 to 4.0. If you go to Documents\R\win-library there will be a version folder with the libraries installed inside. Here is a script that will install the old libraries.

    lib_loc <- "C:/Users/apdev/Documents/R/win-library/3.3"
    to_install <- unname(installed.packages(lib.loc = lib_loc)[, "Package"])
    to_install
    install.packages(pkgs = to_install)
    

    https://community.rstudio.com/t/reinstalling-packages-on-new-version-of-r/7670/4