简体   繁体   English

未从 RStudio 检测到 Rtools

[英]Rtools is not being detected from RStudio

I am using latest R, RStudio and Rtools.我正在使用最新的 R、RStudio 和 Rtools。

-- I have updated the environment variables. -- 我已经更新了环境变量。 Now I can call gcc, or R from command line.现在我可以从命令行调用 gcc 或 R。

While I was trying to publish an app from the RStudio, I get the following error,当我尝试从 RStudio 发布应用程序时,出现以下错误,

Preparing to deploy application...DONE Uploading bundle for application: 64015...Error: * Application depends on package "Rtools" but it is not installed.正在准备部署应用程序...完成 正在上传应用程序包:64015...错误:* 应用程序依赖于包“Rtools”,但尚未安装。 Please resolve before continuing.请在继续之前解决。 Execution halted执行停止

-- I have tried this,On Console, -- 我试过这个,在控制台上,

> find_rtools(T)
Scanning path...
ls : D:\Rtools\bin\ls.exe 
gcc: D:\Rtools\GCC-46~1.3\bin\gcc.exe 
VERSION.txt
Rtools version 3.3.0.1959 
Version: 3.3 
[1] TRUE

So, Rtools seems basically there!所以,Rtools 似乎基本上就在那里!

-- I have checked environment variables, those are OK, as I also mentioned R and gcc can be started from command line -- 我已经检查了环境变量,这些都可以,因为我还提到 R 和 gcc 可以从命令行启动

Yet, I tried to install and check from within RStudio using installr package, it says,然而,我尝试使用 installr 包从 RStudio 中安装和检查,它说,

> install.Rtools()
No need to install Rtools - You've got the relevant version of Rtools installed
> 

-- This is not a possible duplication of this, Rtools not being detected by R I have tried all these. -- 这不是可能的重复, R 没有被 R 检测到我已经尝试了所有这些。 Did not work.不工作。

Please suggest a solution.请提出解决方案。 Thank you very much for your time.非常感谢您的宝贵时间。

I have no idea why RStudio has such kind of problems from time to time but there is a manual work-around described here:我不知道为什么 RStudio 会不时出现此类问题,但此处描述了手动解决方法:

https://github.com/rwinlib/r-base/wiki/Testing-Packages-with-Experimental-R-Devel-Build-for-Windows https://github.com/rwinlib/r-base/wiki/Testing-Packages-with-Experimental-R-Devel-Build-for-Windows

Basically you have to set two environment variables to point to the correct installation path of Rtools:基本上你必须设置两个环境变量来指向 Rtools 的正确安装路径:

Sys.setenv(PATH = paste("C:/Rtools/bin", Sys.getenv("PATH"), sep=";"))
Sys.setenv(BINPREF = "C:/Rtools/mingw_$(WIN)/bin/")

To avoid losing this change after restarting RStudio you could modify your (Windows) environment variables instead or add the following rows to your .Renviron file that is executed at each startup of R.为避免在重新启动 RStudio 后丢失此更改,您可以改为修改 (Windows) 环境变量,或.Renviron添加到每次启动 R 时执行的.Renviron文件中。

BTW: The $(WIN) part is no typo but required so that R can inject "32" or "64" depending on the R version you are using (32 or 64 bit).顺便说一句: $(WIN)部分不是拼写错误,而是必需的,以便 R 可以根据您使用的 R 版本(32 或 64 位)注入“32”或“64”。

Edit 1: See also this r-bloggers article published recently: https://www.r-bloggers.com/quirks-about-running-rcpp-on-windows-through-rstudio/编辑 1:另见最近发表的这篇 r-bloggers 文章: https : //www.r-bloggers.com/quirks-about-running-rcpp-on-windows-through-rstudio/

Note that there are new potential kinds of problems (from R 3.3 onwards), since R ( not RStudio, but R ) adds a BINPREF variable and modifies the Path variable by default , see the Renviron.site file for the latter, on Windows typically eg under C:\\Program Files\\R\\R-3.4.3\\etc :请注意,存在新的潜在问题(从 R 3.3 开始),因为 R(不是 RStudio,而是 R添加了一个BINPREF变量并默认修改了Path变量,请参阅Renviron.site文件了解后者,通常在 Windows 上例如在C:\\Program Files\\R\\R-3.4.3\\etc

PATH="C:\Rtools\bin;${PATH}" 

This might easily conflict for people with a custom path and/or multiple versions of Rtools installed, so I have commented this out with a # .对于安装了自定义路径和/或多个版本的 Rtools 的人来说,这可能很容易发生冲突,所以我用#注释掉了这一点。

For the BINPREF problem, see the Makeconf file, eg under C:\\Program Files\\R\\R-3.4.3\\etc\\x64 :对于BINPREF问题,请参阅Makeconf文件,例如在C:\\Program Files\\R\\R-3.4.3\\etc\\x64

BINPREF ?= c:/Rtools/mingw_64/bin/

I have then modified this to c:/Rtools34/mingw_64/bin/ , which is where I have installed my Rtools34 .然后我将其修改为c:/Rtools34/mingw_64/bin/ ,这是我安装Rtools34
You can do the same for the Makeconf file under the 32-bit arch.您可以对 32 位Makeconf下的Makeconf文件执行相同操作。 sub-directory.子目录。

Via R CMD check not looking for gcc in Rtools directory :通过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文件以进行永久更改。

After searching a lot solutions, finally I delete .Renviron file in C:\\Users\\My name\\Documents.在搜索了很多解决方案后,最后我删除了 C:\\Users\\My name\\Documents 中的 .Renviron 文件。 Then rtools40 works.然后 rtools40 工作。

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

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