R has been installing packages just fine, but suddenly – I can't think of anything relevant that I modified or uninstalled –
it can't find gcc when I run R CMD check in the command prompt, or devtools::check() in the R console; it delivers the following error:
* installing *source* package 'PkgName' ...
** libs
C:/MinGW/bin/gcc -I"C:/PROGRA~1/R/R-34~1.2/include" -DNDEBUG -I"d:/Compiler/gcc-4.9.3/local330/include" -O3 -Wall -std=gnu99 -mtune=core2 -c PkgName-init.c -o PkgName-init.o
C:/MinGW/bin/gcc: not found
I want R to find gcc in C:\Rtools-3.4\mingw_32\bin, which is the location specified in the system PATH; strsplit(Sys.getenv('PATH'), ';') gives
[...]
[4] "c:\\Rtools-3.4\\bin"
[5] "c:\\Rtools-3.4\\mingw_32\\bin"
[7] "C:\\Program Files\\R\\R-3.4.2\\bin\\i386"
[8] "C:\\Program Files\\R\\R-3.4.2\\bin"
[9] "C:\\Program Files\\MiKTeX 2.9\\miktex\\bin\\x64\\"
[...]
How can I tell R not to look in the non-existent directory C:\MinGW, and instead to follow the PATH?
I don't want to install a second copy of MinGW there, as this causes other issues.
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.
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