简体   繁体   English

R 未检测到 Rtools

[英]Rtools not being detected by R

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 上使用 RStudio 构建一个 R package 7. 当我尝试通过 RStudio 的构建面板构建 package 时,我收到:

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:路径变量设置为:

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: Output 当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 version 3.0.2 (2013-09-25) -- 《飞盘起航》。

The Rstudio Version I am using is: 0.97.551.我使用的 Rstudio 版本是:0.97.551。 When I check for updates, I'm told that this is the latest patch.当我检查更新时,我被告知这是最新的补丁。

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

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.事实证明,当我安装 RTools 时,我在安装中遗漏了 R 2.15.x+ 工具链选项,这导致 gcc 永远不会被安装。 Hopefully, this post will serve as a diagnostic guide if RStudio fails to register RTools.如果 RStudio 无法注册 RTools,希望这篇文章将作为诊断指南。

Thank you everyone for your help.感谢大家的帮助。

The RTools install on Windows doesn't select the C compiler to include by default.默认情况下,Windows 上的 RTools 安装不会选择要包含的 C 编译器。 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.我重新运行安装程序并选择/包含 32 位和 64 位 C 编译器。 Problem solved.问题解决了。

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 正常工作。

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 PATH variable.我的解决方法是将 R 工具路径移动到我的PATH变量的前面。

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 BINPREF variable to locate certain executables, including components of RTools. R 使用BINPREF变量来定位某些可执行文件,包括 RTools 的组件。

BINPREF can be set in a number of places. BINPREF可以在很多地方设置。 In my case, it was set in C:/Users/MYUSERNAME/Documents/.R/Makevars .就我而言,它是在C:/Users/MYUSERNAME/Documents/.R/Makevars设置的。 Deleting the contents of this file removed a link to a previous, and since deleted, installation of RTools.删除此文件的内容会删除指向先前已删除的 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.还值得检查文件$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 Make conf file is overwritten when R is updated, you'll have to remember to do this each time.临时修复是将BINPREF ?=替换为BINPREF = ,但是由于更新 R 时 Make conf文件会被覆盖,因此您必须记住每次都这样做。 Better to edit, or delete, the Make vars file for a permanent change.最好编辑或删除 Make vars文件以进行永久更改。

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

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

This error message may appear for Windows users , when the windows user you're logged in as doesn't have permission to add files, or when an anti virus program quarantines (with or without your knowledge) some key files during the R installation.当您登录的 Windows 用户无权添加文件时,或者当防病毒程序在 R 安装期间隔离(无论您是否知情)某些关键文件时, Windows 用户可能会出现此错误消息。

Often, you can solve this by giving the windows user the required permissions通常,您可以通过授予 Windows 用户所需的权限来解决此问题

Background:背景:

  • I tried install.packages("Rtools") but it did not help Rtools isn't an R package, but a standalone installer which cannot be installed via install.packages() (thanks @coatless)我尝试了install.packages("Rtools")但它没有帮助 Rtools 不是 R 包,而是无法通过install.packages()安装的独立安装程序(感谢@coatless)
  • After the windows user had the required permissions, things like `install.packages("tidyverse") succeeded (there was no need to try to reinstall Rtools).在 windows 用户获得所需的权限后,`install.packages("tidyverse") 之类的事情就成功了(无需尝试重​​新安装 Rtools)。
  • Often after turning off anti-virus, uninstalling R, then reinstalling R, everything will work as expected.通常在关闭防病毒软件,卸载 R,然后重新安装 R 后,一切都会按预期进行。

Alternatively, try downloading rtools separately here and simply run the .exe file downloaded to install it - that worked for me.或者,尝试在此处单独下载 rtools,只需运行下载的.exe文件即可安装它 - 这对我有用。

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

Starting with R 4.0.0 (released April 2020), R for Windows uses a brand new toolchain bundle called rtools40.从 R 4.0.0(2020 年 4 月发布)开始,R for Windows 使用名为 rtools40 的全新工具链包。

This version of Rtools upgrades the mingw-w64 gcc toolchains to version 8.3.0, and introduces a new build system based on msys2, which makes easier to build and maintain R itself as well as the system libraries needed by R packages on Windows.此版本的 Rtools 将 mingw-w64 gcc 工具链升级到 8.3.0 版本,并引入了基于 msys2 的新构建系统,这使得构建和维护 R 本身以及 Windows 上 R 包所需的系统库变得更加容易。 For more information about the latter, follow the links at the bottom of this document.有关后者的更多信息,请点击本文档底部的链接。

This documentation is about rtools40, the current version used for R 4.0.0 and newer.本文档是关于 rtools40,当前用于 R 4.0.0 和更新版本的版本。 For information about previous versions of Rtools that can be used with R 3.6.3 or older, please visit this page.有关可与 R 3.6.3 或更早版本一起使用的早期 Rtools 版本的信息,请访问此页面。 Installing Rtools40安装 Rtools40

Note that rtools40 is only needed build R packages with C/C++/Fortran code from source.请注意,rtools40 只需要从源代码使用 C/C++/Fortran 代码构建 R 包。 By default, R for Windows installs the precompiled “binary packages” from CRAN, for which you do not need rtools!默认情况下,R for Windows 安装来自 CRAN 的预编译“二进制包”,您不需要 rtools!

To use rtools40, download the installer from CRAN:要使用 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)

Note for RStudio users: please check you are using the latest version of RStudio (at least 1.2.5042) to work with rtools40. RStudio 用户注意事项:请检查您使用的是最新版本的 RStudio(至少 1.2.5042)来与 rtools40 一起使用。

Putting Rtools on the PATH将 Rtools 放在 PATH 上

After installation is complete, you need to perform one more step to be able to compile R packages: you need to put the location of the Rtools make utilities (bash, make, etc) on the PATH.安装完成后,您还需要执行一个步骤才能编译 R 包:您需要将 Rtools make 实用程序(bash、make 等)的位置放在 PATH 中。 The easiest way to do so is create a text file .Renviron in your Documents folder which contains the following line:最简单的方法是在您的 Documents 文件夹中创建一个文本文件 .Renviron,其中包含以下行:

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

You can do this with a text editor, or you can even do it from R like so:您可以使用文本编辑器执行此操作,或者您甚至可以像这样从 R 执行此操作:

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

Now restart R, and verify that make can be found, which should show the path to your Rtools installation.现在重新启动 R,并验证是否可以找到 make,它应该显示 Rtools 安装的路径。

Sys.which("make") Sys.which("make")

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

If this works, you can try to install an R package from source:如果可行,您可以尝试从源代码安装 R 包:

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

If this succeeds, you're good to go!如果这成功了,你就可以开始了! See the links below to learn more about rtools40 and the Windows build infrastructure.请参阅下面的链接以了解有关 rtools40 和 Windows 构建基础结构的更多信息。

To download Rtools on Windows follow these steps below:要在 Windows 上下载Rtools ,请按照以下步骤操作:

  1. Go to this CRAN website Go 到这个 CRAN 网站

2. Look under the heading "Installing RtoolsXX" eg Rtools42 , there a link is provided to the index. 2. 查看标题“安装 RtoolsXX”(例如Rtools42 )下的内容,其中提供了指向索引的链接。 Visit that link.访问该链接。 3. On the index page, find a file named rtools42-4737-4741.exe , (where 4737-4741 are version numbers and change as new builds are being added). 3. 在索引页上,找到一个名为rtools42-4737-4741.exe的文件(其中 4737-4741 是版本号,随着新版本的添加而变化)。 3. Download and open it to install. 3. 下载并打开安装。

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

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