RTools Not Recognized (RStudio 1.2.5033 / R 3.6.3 / Rtools 3.5)

I recently upgraded from R 3.6.2 and since then I have not been able to successfully install or build packages from source.

R.version
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 6.3
year 2020
month 02
day 29
svn rev 77875
language R
version.string R version 3.6.3 (2020-02-29)
nickname Holding the Windsock

Originally the problem came up when attempting to install a simple package from github:

install_github("braverock/blotter")

Downloading GitHub repo braverock/blotter@master
Error: Failed to install 'blotter' from GitHub:
Could not find tools necessary to compile a package
Call pkgbuild::check_build_tools(debug = TRUE) to diagnose the problem.

So I pulled the package and attempted to build locally:

Running 'Build and Restart' gives the following output:

==> Rcmd.exe INSTALL --no-multiarch --with-keep.source blotter

The system cannot find the path specified.
The system cannot find the path specified.

  • installing to library 'D:/Packages/R'

  • installing source package 'blotter' ...
    ** using staged installation
    ** libs
    make: Nothing to be done for 'all'.
    installing to D:/Packages/R/00LOCK-blotter/00new/blotter/libs/x64
    ** R
    ** data
    ** demo
    ** byte-compile and prepare package for lazy loading
    ** help
    *** installing help indices
    converting help for package 'blotter'
    finding HTML links ... AcctReturns html
    IBM html
    PortfReturns html done

    addAcctTxn html
    addDiv html
    addPortfInstr html
    addTxn html
    amzn html
    blotter-package html
    calcPortfWgt html
    calcPosAvgCost html
    calcTxnAvgCost html
    calcTxnValue html
    chart.ME html
    chart.Posn html
    chart.Reconcile html
    chart.Spread html
    dailyTxnPL html
    extractTxns html
    getAccount html
    getByPortf html
    getBySymbol html
    getEndEq html
    getPortfAcct html
    getPortfolio html
    getPos html
    getPosAvgCost html
    getPosQty html
    getTxns html
    hist.mcsim html
    hist.txnsim html
    initAcct html
    initPortf html
    initPosPL html
    initSummary html
    initTxn html
    is.account html
    is.portfolio html
    mcsim html
    pennyPerShare html
    perTradeStats html
    plot.mcsim html
    plot.txnsim html
    put.account html
    put.portfolio html
    quantile.mcsim html
    quantile.txnsim html
    summary.mcsim html
    summary.txnsim html
    tradeQuantiles html
    tradeStats html
    txnsim html
    txnsim.portfs html
    txnsim.portnames html
    txnsim.txns html
    updateAcct html
    updateEndEq html
    updatePortf html
    updatePosPL html
    ** building package indices
    ** testing if installed package can be loaded from temporary location
    ** testing if installed package can be loaded from final location
    ** testing if installed package keeps a record of temporary installation path

  • DONE (blotter)

Exited with status 1.

Basically, from here on out whenever I try to interact with devtools/packages it says that "Building R packages from source require installation of additional build tools..." prompts)

Checking devtools:

devtools::find_rtools(T)

Gives:

devtools::find_rtools(T)
Scanning R CMD config CC...
cc_path: C:/Rtools/mingw_64/bin/gcc
install_path: C:/Rtools
Found compatible gcc from R CMD config CC
[1] TRUE

Which looks good. However, strangely the command:

pkgbuild::has_compiler(debug = TRUE)

pkgbuild::has_compiler(debug = TRUE)
Trying to compile a simple C file
Running "C:/PROGRA~1/R/R-36~1.3/bin/x64/Rcmd.exe" SHLIB foo.c
The system cannot find the path specified.
C:/Rtools/mingw_64/bin/gcc -I"C:/PROGRA~1/R/R-36~1.3/include" -DNDEBUG -O2 -Wall -std=gnu99 -mtune=core2 -c foo.c -o foo.o
C:/Rtools/mingw_64/bin/gcc -shared -s -static-libgcc -o foo.dll tmp.def foo.o -LC:/PROGRA~1/R/R-36~1.3/bin/x64 -lR
[1] FALSE

Double checked my env variables:

Sys.getenv('BINPREF')
[1] "C:/Rtools/mingw_$(WIN)/bin/"

writeLines(strsplit(Sys.getenv("PATH"), ";")[[1]])
C:\Program Files\R\R-3.6.3\bin\x64
C:\Rtools\bin
C:\Rtools\mingw_64\bin
C:\Program Files\R\R-3.6.3\bin\x64
C:\Program Files (x86)\Common Files\Oracle\Java\javapath
E:\CUDA\Dev\bin
E:\CUDA\Dev\libnvvp
C:\Program Files\Common Files\Microsoft Shared\Microsoft Online Services
C:\Program Files (x86)\Common Files\Microsoft Shared\Microsoft Online Services
C:\Program Files\Microsoft MPI\Bin
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS
C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS
C:\Windows\System32
C:\Windows
C:\Windows\System32\wbem
C:\Windows\System32\WindowsPowerShell\v1.0
C:\Windows\System32\OpenSSH
C:\Program Files\NVIDIA Corporation\NVIDIA NGX
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL
C:\Program Files\Intel\Intel(R) Management Engine Components\DAL
C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
C:\Program Files\Microsoft SQL Server\130\Tools\Binn
C:\Program Files\IDM Computer Solutions\UltraEdit
C:\Program Files\IDM Computer Solutions\UltraCompare
E:\Mingw-w64\bin
C:\Program Files\dotnet
D:\Libraries\glpk-4.65\w64
C:\Program Files\Pandoc
C:\Program Files\Intel\WiFi\bin
C:\Program Files\Common Files\Intel\WirelessCommon
C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn
C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn
C:\Program Files\IDM Computer Solutions\UltraFTP
C:\Program Files\CMake\bin
C:\Program Files\Git\cmd
C:\Program Files (x86)\IncrediBuild
C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn
C:\Program Files\MiKTeX 2.9\miktex\bin\x64
C:\Program Files\Docker\Docker\resources\bin
C:\ProgramData\DockerDesktop\version-bin
C:\Windows\System32
C:\Windows
C:\Windows\System32\wbem
C:\Windows\System32\WindowsPowerShell\v1.0
C:\Windows\System32\OpenSSH
C:\Users\bmore\AppData\Local\Programs\Python\Python38\Scripts
C:\Users\bmore\AppData\Local\Programs\Python\Python38
C:\Users\bmore\AppData\Local\Microsoft\WindowsApps
C:\Users\bmore\AppData\Local\Programs\Microsoft VS Code\bin
C:\Users\bmore\AppData\Local\GitHubDesktop\bin
C:\Program Files\Intel\WiFi\bin
C:\Program Files\Common Files\Intel\WirelessCommon
C:\Users\bmore\AppData\Local\Microsoft\WindowsApps

Sys.which("ls.exe")
ls.exe
"C:\Rtools\bin\ls.exe"

Sys.which("gcc.exe")
gcc.exe
"C:\Rtools\mingw_64\bin\gcc.exe"

Which all look fine (I think).

So, I tried just straight forward compilation of a c source file:

file <- tempfile(fileext = ".c")
writeLines("void test() {}", con = file)
R <- file.path(R.home("bin"), "R")
system2(R, c("CMD", "SHLIB", shQuote(file)))
The system cannot find the path specified.
C:/Rtools/mingw_64/bin/gcc -I"C:/PROGRA~1/R/R-36~1.3/include" -DNDEBUG -O2 -Wall -std=gnu99 -mtune=core2 -c C:\Users\bmore\AppData\Local\Temp\Rtmp44jRG1\file67b41d9918ba.c -o C:\Users\bmore\AppData\Local\Temp\Rtmp44jRG1\file67b41d9918ba.o
gcc.exe: error: C:UsersbmoreAppDataLocalTempRtmp44jRG1file67b41d9918ba.c: No such file or directory
gcc.exe: fatal error: no input files
compilation terminated.
make: *** [C:/PROGRA~1/R/R-36~1.3/etc/x64/Makeconf:208: C:\Users\bmore\AppData\Local\Temp\Rtmp44jRG1\file67b41d9918ba.o] Error 1

And of course, the gcc path is missing all slashes in the file name, which is extremely odd but maybe a symptom of a larger issue. So, I just wrote out the C code in a regular flat-file and tried compiling it again:

test.file <- file.path("D:/GitHub/ctest.c")
R <- file.path(R.home("bin"), "R")
system2(R, c("CMD", "SHLIB", shQuote(test.file)))
The system cannot find the path specified.
C:/Rtools/mingw_64/bin/gcc -I"C:/PROGRA~1/R/R-36~1.3/include" -DNDEBUG -O2 -Wall -std=gnu99 -mtune=core2 -c D:/GitHub/ctest.c -o D:/GitHub/ctest.o
C:/Rtools/mingw_64/bin/gcc -shared -s -static-libgcc -o D:/GitHub/ctest.dll tmp.def D:/GitHub/ctest.o -LC:/PROGRA~1/R/R-36~1.3/bin/x64 -lR

Oddly enough, it does compile, there is a .o and .dll file now in the path, however, it doesn't detect the success for some reason ("the system cannot find the specified path" error still).

I am pretty lost and confused on where to go from here and any help would be greatly appreciated.

If anyone else is having a similar issue, the root cause was 'The system cannot find the path specified' error in the command line itself.

This was ultimately traced back to 'Anaconda' which I had uninstalled a while ago, however, the uninstaller DOES NOT clean-up the registry upon removal. You have to do the following:

  1. Open the Registry Editor (press +R, type regedit and hit Enter) .
  2. Navigate to HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun and clear the values.
  3. Also, check HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun .
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.