我安装了R,RStudio和devtools(下面省略了一些输出)并进行了更新。我还安装了Rtools的最新版本:
# Check R version
R.Version()
$platform
[1] "x86_64-w64-mingw32"
# OUTPUT OMITTED
$version.string
[1] "R version 3.4.3 (2017-11-30)"
# Check devtools for Rtools installation
devtools::find_rtools()
[1] TRUE
Run Code Online (Sandbox Code Playgroud)
但是,当我按Ctrl + Shift + B在RStudio中构建软件包时,会通知我找不到Rtools:
==> devtools::build()
"C:/PROGRA~1/R/R-34~1.3/bin/x64/R" --no-site-file --no-environ --no-save \
--no-restore --quiet CMD build \
"C:\Users\name\mypkg" --no-resave-data \
--no-manual
* checking for file
'C:\Users\name/mypkg/DESCRIPTION' ... OK
* preparing 'mypkg':
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* building 'mypkg_0.1.0.tar.gz'
[1] "C:/Users/name/mypkg_0.1.0.tar.gz"
Source package written to C:/Users/brett/Dropbox/Duke/package_development
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/Rtools/
Run Code Online (Sandbox Code Playgroud)
关于此问题的先前文章(请参阅:Rtools未被R检测)专注于系统路径,但未指定如何设置它或在何处。此外,该帖子中的OP在Rtools安装过程中未包含写入工具链选项,或者该路径的路径不正确(R 3.3.0在Windows上安装软件包:找不到gcc错误)。就我而言,两个工具链框均已选中(显示图像)在显示系统路径的代码下方。
# Check system path
Sys.getenv()['PATH']
PATH C:/Rtools/bin;C:\Rtools\bin;C:\Program
Files\R\R-3.4.3\bin\x64;C:\Rtools\bin;C:\Program
Files (x86)\Intel\iCLS Client\;C:\Program
Files\Intel\iCLS
Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program
Files (x86)\Intel\Intel(R) Management Engine
Components\DAL;C:\Program Files\Intel\Intel(R)
Management Engine Components\DAL;C:\Program
Files (x86)\Intel\Intel(R) Management Engine
Components\IPT;C:\Program Files\Intel\Intel(R)
Management Engine Components\IPT;C:\Program
Files\MiKTeX 2.9\miktex\bin\x64\;C:\Program
Files
(x86)\PharosSystems\Core;C:\WINDOWS\System32\OpenSSH\;C:\Users\name\AppData\Local\Microsoft\WindowsApps;
Run Code Online (Sandbox Code Playgroud)
我怀疑路径仍然是问题所在,但此处的解决方案并未确切说明应寻找的内容,如何找到它以及最终的解决方案是什么样的:RStudio找不到Rtools来构建软件包
有人可以提供有关在Rstudio中检测rtool的解决方案的建议吗?
我以这种方式对问题进行了分类,部分是通过对该问题的评论进行引导的:
鉴于devtools::find_rtools()返回的内容TRUE以及使用Rcpp(https://thecoatlessprofessor.com/programming/installing-rtools-for-compiled-code-via-rcpp/)进行的本页面末尾的检查,都可以使用:
尝试Sys.which("ls.exe")和Sys.which("gcc.exe")。前者应返回路径,但后者可能为空,这就是问题所在。
然后,我找到了的另一个副本gcc.exe(在我的情况下C:\Rtools\mingw_64\bin,这是个令人发狂的副本),然后将其复制到C:\Rtools\bin,这是RStudio想要的副本。那是ls.exe使用找到的Sys.which。那为我解决了问题。