简体   繁体   English

如何为 R 设置 Rtools PATH

[英]How to set Rtools PATH for R

I am having trouble with rtools .我在使用rtools时遇到问题。 Sys.which("make") yields an empty vector (working from R Studio ) Sys.which("make")产生一个空向量(来自R Studio

Sys.which("make")

"" “”

This is my R Version这是我的 R 版本

R.Version()$version.string

[1] "R version 4.1.3 (2022-03-10)" [1] 《R 版本 4.1.3 (2022-03-10)》

Apparently, this is an issue with my PATH .显然,这是我的PATH的问题。

Sys.getenv("PATH")

C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Users\...\Miniconda3;C:\Users\...\Miniconda3\Library\mingw-w64\bin;C:\Users\...\Miniconda3\Library\usr\bin;C:\Users\...\Miniconda3\Library\bin;C:\Users\...\Miniconda3\Scripts;C:\Users\...\AppData\Local\Programs\Python\Python39\Scripts\;C:\Users\...\AppData\Local\Programs\Python\Python39\;C:\Users\...\AppData\Local\Microsoft\WindowsApps;C:\Users\...\AppData\Local\Programs\Microsoft VS Code\bin" C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Users\ ...\Miniconda3;C:\Users\...\Miniconda3\Library\mingw-w64\bin;C:\Users\...\Miniconda3\Library\usr\bin;C:\Users\... \Miniconda3\Library\bin;C:\Users\...\Miniconda3\Scripts;C:\Users\...\AppData\Local\Programs\Python\Python39\Scripts\;C:\Users\... \AppData\Local\Programs\Python\Python39\;C:\Users\...\AppData\Local\Microsoft\WindowsApps;C:\Users\...\AppData\Local\Programs\Microsoft VS Code\bin"

I have tried to set the PATH to rtools the following.我尝试将PATH设置为以下rtools

I have created a ~/.Renviron file我创建了一个~/.Renviron文件

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

I also have tried this one我也试过这个

file.edit(file.path("~", ".Rprofile"))
Sys.setenv(PATH = paste("C:/Rtools/bin", Sys.getenv("PATH"), sep=";"))

However, still no luck.然而,仍然没有运气。 How do I set the path to rtools ?如何设置rtools的路径?

This is how I solved it:这就是我解决它的方法:

  1. By looking at my PATH variable, which you get through通过查看我的PATH变量,您可以通过

Sys.getenv("PATH")

I saw that it pointed rtools to c:\rtools40\ .我看到它将rtools指向c:\rtools40\ However, this should be c:\rtools40\usr\bin .但是,这应该是c:\rtools40\usr\bin I edited the environment Variable accordingly.我相应地编辑了环境变量。 Here is an instruction how to edit the environment variables on windows. 这是一个说明如何在 windows 上编辑环境变量。

  1. I also added this to the .Renviron file:我还将其添加到.Renviron文件中:

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

The .Renviron file should be created/located accordingly to this location应根据此位置创建/定位.Renviron文件

Sys.getenv("HOME")

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

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