简体   繁体   English

R CMD检查不在Rtools目录中寻找gcc

[英]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; R一直在安装软件包,但突然–我想不到我修改或卸载的任何相关文件–在命令提示符下运行R CMD check或在以下目录中的devtools::check() ,找不到gcc R控制台; 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; 我想让R在C:\\ Rtools-3.4 \\ mingw_32 \\ bin中找到gcc,这是在系统PATH中指定的位置; strsplit(Sys.getenv('PATH'), ';') gives strsplit(Sys.getenv('PATH'), ';')给出

[...]
[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? 如何告诉R不要在不存在的目录C:\\ MinGW中查找,而是遵循PATH?

I don't want to install a second copy of MinGW there, as this causes other issues. 我不想在那里安装第二个MinGW副本,因为这会导致其他问题。

R uses a BINPREF variable to locate executables: the location of the gcc executable is given by CC = $(BINPREF)gcc $(M_ARCH) R使用BINPREF变量定位可执行文件:gcc可执行文件的位置由CC = $(BINPREF)gcc $(M_ARCH)

In my case, BINPREF was being set by C:/Users/MYUSERNAME/Documents/.R/Makevars . 就我而言, BINPREF是由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. 还值得检查$RPATH/etc/i386/Makeconf ,该文件将在每次新安装R时重新创建。请注意行BINPREF ?= c:/Rtools/mingw_32/bin/ ,其中(通过?=运算符)将设置BINPREF的值(如果尚未设置),如上面提到的Makevars文件中那样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM