63

更新:

我已经写了一个关于在 windows 上安装 Rtools的简要演练指南。

原来的:

我正在尝试在 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/

加载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

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\

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

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\\" 

我正在使用的 R 版本是:R 版本 3.0.2 (2013-09-25) -- “Frisbee Sailing”。

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

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

8 回答 8

20

结果是,当我安装 RTools 时,我在安装中遗漏了 R 2.15.x+ 工具链选项,这导致 gcc 永远不会被安装。如果 RStudio 注册 RTools 失败,希望这篇文章可以作为诊断指南。

感谢大家的帮助。

于 2013-11-14T05:20:17.133 回答
6

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

于 2014-02-20T05:53:41.127 回答
5

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

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

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

于 2016-07-20T12:24:10.873 回答
4

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

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

于 2019-01-24T00:34:19.450 回答
2

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 uses a BINPREF variable to locate certain executables, including components of RTools.

BINPREF can 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.

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 BINPREF if it is not already set, as it was in the Makevars file mentioned above.

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

于 2019-06-10T11:43:31.423 回答
1

R 找不到 Rtools。


90% 的时间,重新安装 Rtools 将解决

  1. 这个网站
  2. 下载 rtools
  3. 找到刚刚下载的文件
  4. 双击它开始安装
  5. 关闭并重新打开 RStudio
  6. 现在一切都应该正常了!

进一步阅读和其他可能的解决方案可以在这里找到

于 2020-12-20T01:31:24.193 回答
0

您可以通过键入以下命令将 Rtools 添加到您的路径中:

writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron")
于 2020-07-06T15:48:32.787 回答
0

https://cran.r-project.org/bin/windows/Rtools/

从 R 4.0.0(2020 年 4 月发布)开始,R for Windows 使用名为 rtools40 的全新工具链包。

此版本的 Rtools 将 mingw-w64 gcc 工具链升级到 8.3.0 版本,并引入了基于 msys2 的新构建系统,这使得 R 本身以及 Windows 上 R 包所需的系统库更容易构建和维护。有关后者的更多信息,请点击本文档底部的链接。

本文档是关于 rtools40,用于 R 4.0.0 和更新版本的当前版本。有关可用于 R 3.6.3 或更早版本的 Rtools 早期版本的信息,请访问此页面。安装 Rtools40

请注意,仅需要 rtools40 使用源代码中的 C/C++/Fortran 代码构建 R 包。默认情况下,R for Windows 安装来自 CRAN 的预编译“二进制包”,您不需要 rtools!

要使用 rtools40,请从 CRAN 下载安装程序:

On Windows 64-bit: rtools40-x86_64.exe (recommended: includes both i386 and x64 compilers)
On Windows 32-bit: rtools40-i686.exe (i386 compilers only)

RStudio 用户注意事项:请检查您是否使用最新版本的 RStudio(至少 1.2.5042)来使用 rtools40。

将 Rtools 放在 PATH 上

安装完成后,您需要再执行一个步骤才能编译 R 包:您需要将 Rtools make 实用程序(bash、make 等)的位置放在 PATH 上。最简单的方法是在 Documents 文件夹中创建一个文本文件 .Renviron,其中包含以下行:

PATH="${RTOOLS40_HOME}\usr\bin;${PATH}"

您可以使用文本编辑器执行此操作,或者您甚至可以从 R 执行此操作,如下所示:

writeLines('PATH="${RTOOLS40_HOME}\usr\bin;${PATH}"', con = "~/.Renviron")

现在重新启动 R,并验证是否可以找到 make,它应该显示 Rtools 安装的路径。

Sys.which("make")

"C:\rtools40\usr\bin\make.exe"

如果可行,您可以尝试从源代码安装 R 包:

install.packages("jsonlite", type = "source")

如果这成功了,你就可以开始了!请参阅下面的链接以了解有关 rtools40 和 Windows 构建基础架构的更多信息。

于 2021-03-27T23:32:53.143 回答