I have R, RStudio, and devtools installed (some output below omitted) and updated. I have also installed the most recent version of Rtools:
# Check R version
R.Version()
$platform
[1] "x86_64-w64-mingw32"
# OUTPUT OMITTED
$version.string
[1] "R version 3.4.3 (2017-11-30)"
# Check devtools for Rtools installation
devtools::find_rtools()
[1] TRUE
Yet when I press Ctrl + Shift + B to build a package in RStudio, I am informed Rtools is not found:
==> devtools::build()
"C:/PROGRA~1/R/R-34~1.3/bin/x64/R" --no-site-file --no-environ --no-save \
--no-restore --quiet CMD build \
"C:\Users\name\mypkg" --no-resave-data \
--no-manual
* checking for file
'C:\Users\name/mypkg/DESCRIPTION' ... OK
* preparing 'mypkg':
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* building 'mypkg_0.1.0.tar.gz'
[1] "C:/Users/name/mypkg_0.1.0.tar.gz"
Source package written to C:/Users/brett/Dropbox/Duke/package_development
WARNING: Rtools is required to build R packages but is not currently
installed. Please download and install the appropriate version of Rtools
before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/
Previous posts on this issue (see: Rtools not being detected by R) have focused on the system path, but not specified how to set it or where. Furthermore, the OP in that post wrote the toolchain option was not included during the Rtools installation or the directory is incorrect for the path (R 3.3.0 installing a package on Windows: gcc not found error). In my case, both toolchain boxes have been checked (see image) below the code showing the system path.
# Check system path
Sys.getenv()['PATH']
PATH C:/Rtools/bin;C:\Rtools\bin;C:\Program
Files\R\R-3.4.3\bin\x64;C:\Rtools\bin;C:\Program
Files (x86)\Intel\iCLS Client\;C:\Program
Files\Intel\iCLS
Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program
Files (x86)\Intel\Intel(R) Management Engine
Components\DAL;C:\Program Files\Intel\Intel(R)
Management Engine Components\DAL;C:\Program
Files (x86)\Intel\Intel(R) Management Engine
Components\IPT;C:\Program Files\Intel\Intel(R)
Management Engine Components\IPT;C:\Program
Files\MiKTeX 2.9\miktex\bin\x64\;C:\Program
Files
(x86)\PharosSystems\Core;C:\WINDOWS\System32\OpenSSH\;C:\Users\name\AppData\Local\Microsoft\WindowsApps;
I suspect the path is still somehow the problem, but the solution here doesn't specify exactly what one should look for, how to find it, and what the final solution looks like: RStudio cannot find Rtools to build package
Can someone offers suggestions on solutions to detect rtools in Rstudio?
I have sorted the problem in this way, partly guided by the comments on the question at:
Rtools not being detected by R
Given that devtools::find_rtools()
returns TRUE
and the check at the end of this webpage using Rcpp
(https://thecoatlessprofessor.com/programming/installing-rtools-for-compiled-code-via-rcpp/) works:
Try Sys.which("ls.exe")
and Sys.which("gcc.exe")
. The former should return a path, but the latter may be empty, which is the problem.
I then found another copy of gcc.exe
(in my case it there was one at C:\Rtools\mingw_64\bin
, which is a bit maddening) and copied it into C:\Rtools\bin
, which is where RStudio seems to want it. That is where ls.exe
was found using the Sys.which
. That solved the problem for me.
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