Dear community,
I am running into a persistent toolchain issue when trying to compile C/C++ code from R on a Windows machine (institutional managed environment).
- R version:
R version 4.6.0 (2026-04-24 ucrt) - Rtools: Rtools45 installed in
C:\rtools45 Sys.which("make")returnsC:\\rtools45\\usr\\bin\\make.exe, so R is seeing the Rtools45makebinary.
Even when I work from a local directory where I have full access, a simple build-tools check fails:
r
getwd()
# [1] "/home/k/Username/Documents" # default institutional home
setwd("C:/Users/Username/Downloads") # local folder I fully control
install.packages("pkgbuild", type = "binary")
library(pkgbuild)
check_build_tools(debug = TRUE)
This produces:
text
Trying to compile a simple C file
Running "C:/PROGRA~1/R/R-46~1.0/bin/x64/Rcmd.exe" SHLIB foo.c
Error in system(paste(MAKE, p1(paste("-f", shQuote(makefiles))), "compilers"), :
'CreateProcess' failed to run 'C:\rtools45\usr\bin\make.exe -f "C:/PROGRA~1/R/R-46~1.0/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-46~1.0/share/make/winshlib.mk" compilers'
Calls: <Anonymous> -> .shlib_internal -> system
Execution halted
trying URL 'https://cloud.r-project.org/bin/windows/Rtools/rtools44/files/rtools44-6459-6401.exe'
Content type 'application/x-msdownload' length 451591776 bytes (430.7 MB)
downloaded 430.7 MB
Error: Could not find tools necessary to compile a package
Call `pkgbuild::check_build_tools(debug = TRUE)` to diagnose the problem.
It seems:
- R correctly locates
make.exefrom Rtools45. - When
pkgbuild(and similarlybrms/ Stan) try to compile a trivial test C file viaR CMD SHLIB, Windows’CreateProcesscall fails to spawnC:\rtools45\usr\bin\make.exewith the given arguments. - Because this check fails,
pkgbuildthen attempts to download “build tools” and falls back to the Rtools44 URL, which does not resolve the underlying issue.
I have already:
- Updated
pkgbuildand the modeling packages (e.g.,brms) from binaries for R 4.6. - Moved the working directory to a local folder on
C:where I have full write access. - Verified that
Sys.which("make")points to Rtools45.
At this point, it looks like a different problem I cannot define rather than an R-only configuration issue.
Would you have any suggestions ?