R Cmd Check Not Looking for Gcc in Rtools Directory

R CMD check not looking for gcc in Rtools directory

R uses a BINPREF variable to locate executables:
the location of the gcc executable is given by CC = $(BINPREF)gcc $(M_ARCH)

In my case, BINPREF was being set by C:/Users/MYUSERNAME/Documents/.R/Makevars. Deleting the contents of this file removed the incorrect location.

It is also worth checking the file $RPATH/etc/i386/Makeconf, 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.

RStudio not finding RTools

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.

Rtools not found by devtools, but ls and gcc are on PATH

This was a problem in the registry generated during installation, so I reinstalled it and it worked.

Rtools not being detected by R

Turns out when I installed RTools I left out the R 2.15.x+ toolchain option in the installation, which lead to the gcc never being installed. Hopefully, this post will serve as a diagnostic guide if RStudio fails to register RTools.

Thank you everyone for your help.

Warning message: 'c:/Rtools/mingw_/bin/g++' not found

delete your old .Rprofile and try again. This helped in my case

How to avoid cannot find -lR for R Package installation on windows

You are making three mistakes:

  1. You should not install rtools under program files or any other path with a space.
  2. You are using BINPREF wrong, causing the 64-bit toolchain to be used on 32-bit.
  3. The mingw gcc dirs should not be on the PATH. Only the bin dir (bash and make) should be.

Recommended setup:

It is highly recommended to install rtools in the default location C:\Rtools\. This is the only configuration that is widely tested.

In this case you only need to make put C:\Rtools\bin is on the PATH in order to compile packages. R will automatically use the correct compilers on 32-bit and 64-bit.

With non-default Rtools location:

If you really must install rtools in a non standard location, you can set BINPREF to a pattern that includes $(WIN) that gets expanded to the correct path for example like so:

Sys.setenv(BINPREF="C:/YourRtoolsPath/mingw_$(WIN)/bin/")

When make invokes the compiler, $(WIN) gets substituted by either 32 or 64 which should then resolve to the correct path of the respective toolchain.



Related Topics



Leave a reply



Submit