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.
Installing RToolsGo to https://cran.r-project.org/, click on 'Download R for Windows', then 'Rtools', and select the very latest version of RTools to download. After downloading has completed run the installer. Select the default options everywhere.
has_rtools() determines if Rtools is installed, caching the results. Afterward, run rtools_path() to find out where it's installed.
Go to "Control Panel -> System." Click on the tab "Advanced" and then on "Environment Variables." Highlight "Path" at the bottom and click "Edit". In the character string in "Variable Value", you want c:\Rtools\bin;c:\Rtools\perl\bin;c:\Rtools\MinGW\bin;c:\R\bin and then any other stuff at the end.
On a windows machine with R 3.5.1, install Rtools in C:/Rbuildtools. This is the path by default where the installer install Rtools. The installer is the one that you get when your are inside Rstudio and pkgbuild::has_build_tools() does not find Rtools.
If you installed R to a non-default location, it is possible RStudio cannot find R on your machine. Open a standard console session (RGui, R.app, Terminal, etc) and type the following command at the console: The displayed location must be in your search path for RStudio to successfully bind to your R installation.
A short version of my question is why pkgbuild can find Rtools, but Rstudio cannot. The finding mechanism are not the same I think. One is inside the package, the other is inside RStudio and it seems they are not identical. In RStudio on windows, I often use pkgbuild::with_build_tools () to run safely being sure RTools is found.
Another possible cause is for R to be looking in the wrong directory for RTools components, via R CMD check not looking for gcc in Rtools directory: R uses a BINPREF variable to locate certain executables, including components of RTools.
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/
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With