R CMD check not looking for gcc in Rtools directory

被刻印的时光 ゝ 提交于 2019-12-29 09:25:11

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/47076620/r-cmd-check-not-looking-for-gcc-in-rtools-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!