RStudio 找不到 Rtools 来构建包

RStudio cannot find Rtools to build package

我在 Windows 10 机器上安装了 R 3.5.0 和 Rtools 3.5。 运行 devtools::find_rtools() 产生 TRUE 但是当我尝试检查并构建我正在处理的包时,出现错误:

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

https://cran.rstudio.com/bin/windows/

基于此link我运行以下命令但得到相同的错误:

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

如何让 Rtools 被识别来构建包?

原来我还需要将 c:\Rtools\mingw_64\bin; 添加到我的 PATH 中。