windows R 未检测到 Rtools

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19885381/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 11:04:11  来源:igfitidea点击:

Rtools not being detected by R

windowsrrstudio

提问by coatless

Update:

更新:

I've written a brief walkthrough guide to installing Rtools on windows.

我写了一个在 windows安装 Rtools的简短演练指南。

Original:

原来的:

I am trying to build an R package using RStudio on Windows 7. When I attempt to build the package via RStudio's Build panel I receive:

我正在尝试在 Windows 7 上使用 RStudio 构建 R 包。当我尝试通过 RStudio 的构建面板构建包时,我收到:

WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:

http://cran.rstudio.com/bin/windows/Rtools/

Loading library(devtools)and running find_rtools(T)gives:

加载library(devtools)和运行find_rtools(T)给出:

Scanning path...
ls : F:\Rtools\bin\ls.exe 
Scanning registry...
Found F:/Rtools for 3.1 
VERSION.txt
Rtools version 3.1.0.1936 
[1] TRUE

The Path variable is set as:

Path 变量设置为:

F:\Rtools\bin;F:\Rtools\gcc-4.6.3\bin;F:\Rtools\perl\bin;F:\Rtools\MinGW\bin;F:\Program Files\R\R-3.0.2\bin\x64;F:\Program Files (x86)\HTML Help Workshop;F:\Program Files\MiKTeX 2.9\miktex\bin\x64\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\Microsoft Network Monitor 3\;F:\Program Files (x86)\QuickTime\QTSystem\

I've also restarted several times, yet the error persists. I'm a bit confused as to why this is occurring.

我也重新启动了几次,但错误仍然存​​在。我对为什么会发生这种情况感到有些困惑。

Output when R access system variable Path:

R访问系统变量Path时的输出:

> Sys.getenv()['PATH']
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 PATH 
"F:\Program Files\R\R-3.0.2\bin\x64;F:\Rtools\bin;F:\Rtools\gcc-4.6.3\bin;F:\Rtools\perl\bin;F:\Rtools\MinGW\bin;F:\Program Files\R\R-3.0.2\bin\x64;F:\Program Files (x86)\HTML Help Workshop;F:\Program Files\MiKTeX 2.9\miktex\bin\x64\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\Microsoft Network Monitor 3\;F:\Program Files (x86)\QuickTime\QTSystem\" 

The R version I am using is: R version 3.0.2 (2013-09-25) -- "Frisbee Sailing."

我使用的 R 版本是:R 版本 3.0.2 (2013-09-25) -- “飞盘航行”。

The Rstudio Version I am using is: 0.97.551. When I check for updates, I'm told that this is the latest patch.

我使用的 Rstudio 版本是:0.97.551。当我检查更新时,我被告知这是最新的补丁。

> Sys.which("ls.exe")
                   ls.exe 
"F:\Rtools\bin\ls.exe" 
> Sys.which("gcc.exe")
gcc.exe 
     "" 

采纳答案by coatless

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.

事实证明,当我安装 RTools 时,我在安装中遗漏了 R 2.15.x+ 工具链选项,这导致 gcc 永远不会被安装。如果 RStudio 无法注册 RTools,希望这篇文章将作为诊断指南。

Thank you everyone for your help.

感谢大家的帮助。

回答by Andrew Rothstein

The RTools install on Windows doesn't select the C compiler to include by default. I ran the install a few times blindly clicking through and got this error. I reran the installer and selected/included the 32bit and 64bit C compilers. Problem solved.

默认情况下,Windows 上的 RTools 安装不会选择要包含的 C 编译器。我盲目地点击了几次安装并得到了这个错误。我重新运行安装程序并选择/包含 32 位和 64 位 C 编译器。问题解决了。

回答by Zap

It may as well be added that if you don't have admin rights on your computer the installation of Rtools will fail due to some missing registry permissions.

还可以补充一点,如果您在计算机上没有管理员权限,则 Rtools 的安装将由于缺少某些注册表权限而失败。

Took me quite some time to figure that out because if you install Rtools via R you won't see this alert.

我花了很长时间才弄清楚这一点,因为如果您通过 R 安装 Rtools,您将看不到此警报。

So better download the .exe-file, install it as admin and tick the boxes mentioned above to get Rtools working properly.

所以最好下载 .exe 文件,以管理员身份安装它并勾选上面提到的框以使 Rtools 正常工作。

回答by geneorama

I had the same error, and I had installed the tool chain (I believe).

我有同样的错误,我已经安装了工具链(我相信)。

My fix was to move the R Tools paths to the front of my PATHvariable.

我的解决方法是将 R 工具路径移到PATH变量的前面。

回答by ms609

Another possible cause is for R to be looking in the wrong directory for RTools components, via R CMD check not looking for gcc in Rtools directory:

另一个可能的原因是 R 在错误的目录中查找 RTools 组件,通过R CMD 检查而不是在 Rtools 目录中查找 gcc

R uses a BINPREFvariable to locate certain executables, including components of RTools.

R 使用BINPREF变量来定位某些可执行文件,包括 RTools 的组件。

BINPREFcan be set in a number of places. In my case, it was set in C:/Users/MYUSERNAME/Documents/.R/Makevars. Deleting the contents of this file removed a link to a previous, and since deleted, installation of RTools.

BINPREF可以在很多地方设置。就我而言,它设置在C:/Users/MYUSERNAME/Documents/.R/Makevars. 删除此文件的内容会删除指向先前已删除的 RTools 安装的链接。

It is also worth checking the file $RPATH/etc/i386/Makeconf(swap i386 for x64 if you have a 64-bit installation), 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 BINPREFif it is not already set, as it was in the Makevars file mentioned above.

还值得检查该文件$RPATH/etc/i386/Makeconf(如果您有 64 位安装,则将 i386 替换为 x64),它将在每次新安装 R 时重新创建。注意行 BINPREF ?= c:/Rtools/mingw_32/bin/,它(通过?=操作员)将设置值BINPREF如果它还没有设置,就像在上面提到的 Makevars 文件中一样。

A temporary fix is to replace BINPREF ?=with BINPREF =, but as the Makeconffile is overwritten when R is updated, you'll have to remember to do this each time. Better to edit, or delete, the Makevarsfile for a permanent change.

临时修复是替换BINPREF ?=BINPREF =,但是由于更新 R 时Make conf文件会被覆盖,因此您必须记住每次都这样做。最好编辑或删除 Make vars文件以进行永久更改。