R version 4.6.0 keeps pulling wrong RTools version

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") returns C:\\rtools45\\usr\\bin\\make.exe, so R is seeing the Rtools45 make binary.

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.exe from Rtools45.
  • When pkgbuild (and similarly brms / Stan) try to compile a trivial test C file via R CMD SHLIB, Windows’ CreateProcess call fails to spawn C:\rtools45\usr\bin\make.exe with the given arguments.
  • Because this check fails, pkgbuild then attempts to download “build tools” and falls back to the Rtools44 URL, which does not resolve the underlying issue.

I have already:

  • Updated pkgbuild and 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 ?

1 Like

pkgbuild never downloads Rtools, so this must be something else.

2 Likes

Any idea what it could be ? I already tried to uninstall and re-install awith the newest versions

1 Like

First, please copy and paste the full input and output, to make sure that we can see all details.

Second, what is your RStudio version? Does this happen outside of RStudio? E.g. if you start R from a windows terminal?

1 Like