Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
688 views
in Technique[技术] by (71.8m points)

windows - R CMD check not looking for gcc in Rtools directory

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.4mingw_32in, 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...