代码之家  ›  专栏  ›  技术社区  ›  socialscientist

RStudio未找到RTools

  •  4
  • socialscientist  · 技术社区  · 8 年前

    # 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
    

    然而,当我按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/
    

    以前关于这个问题的文章(见: Rtools not being detected by R R 3.3.0 installing a package on Windows: gcc not found error ). 在我的例子中,在显示系统路径的代码下面,两个工具链框都被选中(参见图)。

    # 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;
    

    enter image description here

    RStudio cannot find Rtools to build package

    有人能为Rstudio中检测rtools的解决方案提供建议吗?

    1 回复  |  直到 8 年前
        1
  •  8
  •   CJB    7 年前

    我以这种方式对问题进行了分类,部分是根据对以下问题的评论:

    Rtools not being detected by R

    既然如此 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

    推荐文章