23
votes

I am using latest R, RStudio and Rtools.

-- I have updated the environment variables. Now I can call gcc, or R from command line.

While I was trying to publish an app from the RStudio, I get the following error,

Preparing to deploy application...DONE Uploading bundle for application: 64015...Error: * Application depends on package "Rtools" but it is not installed. Please resolve before continuing. Execution halted

-- I have tried this,On Console,

> find_rtools(T)
Scanning path...
ls : D:\Rtools\bin\ls.exe 
gcc: D:\Rtools\GCC-46~1.3\bin\gcc.exe 
VERSION.txt
Rtools version 3.3.0.1959 
Version: 3.3 
[1] TRUE

So, Rtools seems basically there!

-- I have checked environment variables, those are OK, as I also mentioned R and gcc can be started from command line

Yet, I tried to install and check from within RStudio using installr package, it says,

> install.Rtools()
No need to install Rtools - You've got the relevant version of Rtools installed
> 

-- This is not a possible duplication of this, Rtools not being detected by R I have tried all these. Did not work.

Please suggest a solution. Thank you very much for your time.

4
What exactly is the command you are running that returns the error? It's looking for an "'Rtools' package" which seems different that just looking for Rtools to be installed. Did you write your own package? Did you specify the dependencies correctly? - MrFlick
A lot of people make similar mistakes, Rtools is not a package. Its development environment that you need to install. You may read more from here, cran.r-project.org/bin/windows/Rtools - Droid-Bird
I have tested the same on two computers. No luck! What am I missing? - Droid-Bird
I have similar problems and not yet a solution (with R3.4.0 and RStudio 1.0.143). Funny thing: If I execute devtools::find_rtools(F, T) RTools is found (until I restart the R session). - R Yoda
The issue is a bug with RStudio not recognizing the custom RTools directory. Try to keep it with C:/ if at all possible. I think a fix was added in V1.1.0 >= - coatless

4 Answers

30
votes

I have no idea why RStudio has such kind of problems from time to time but there is a manual work-around described here:

https://github.com/rwinlib/r-base/wiki/Testing-Packages-with-Experimental-R-Devel-Build-for-Windows

Basically you have to set two environment variables to point to the correct installation path of Rtools:

Sys.setenv(PATH = paste("C:/Rtools/bin", Sys.getenv("PATH"), sep=";"))
Sys.setenv(BINPREF = "C:/Rtools/mingw_$(WIN)/bin/")

To avoid losing this change after restarting RStudio you could modify your (Windows) environment variables instead or add the following rows to your .Renviron file that is executed at each startup of R.

BTW: The $(WIN) part is no typo but required so that R can inject "32" or "64" depending on the R version you are using (32 or 64 bit).

Edit 1: See also this r-bloggers article published recently: https://www.r-bloggers.com/quirks-about-running-rcpp-on-windows-through-rstudio/

2
votes

Note that there are new potential kinds of problems (from R 3.3 onwards), since R (not RStudio, but R) adds a BINPREF variable and modifies the Path variable by default, see the Renviron.site file for the latter, on Windows typically e.g. under C:\Program Files\R\R-3.4.3\etc:

PATH="C:\Rtools\bin;${PATH}" 

This might easily conflict for people with a custom path and/or multiple versions of Rtools installed, so I have commented this out with a #.

For the BINPREF problem, see the Makeconf file, e.g. under C:\Program Files\R\R-3.4.3\etc\x64:

BINPREF ?= c:/Rtools/mingw_64/bin/

I have then modified this to c:/Rtools34/mingw_64/bin/, which is where I have installed my Rtools34.
You can do the same for the Makeconf file under the 32-bit arch. sub-directory.

1
votes

Via R CMD check not looking for gcc in Rtools directory:

R uses a BINPREF variable to locate certain executables, including components of RTools.

BINPREF can be set in a number of places. In my case, it was set in C:/Users/MYUSERNAME/Documents/.R/Makevars. Deleting the contents of this file removed a link to a previous, and since deleted, installation of RTools.

It is also worth checking the file $RPATH/etc/i386/Makeconf (swap i386 for x64 if you have a 64-bit installation), which will be re-created with each new installation of R. Note the line BINPREF ?= c:/Rtools/mingw_32/bin/, which (via the ?= operator) will set the value of BINPREF if it is not already set, as it was in the Makevars file mentioned above.

A temporary fix is to replace BINPREF ?= with BINPREF =, but as the Makeconf file is overwritten when R is updated, you'll have to remember to do this each time. Better to edit, or delete, the Makevars file for a permanent change.

1
votes

After searching a lot solutions, finally I delete .Renviron file in C:\Users\My name\Documents. Then rtools40 works.