Error in compileCode(f, code, language = language, verbose = verbose) :

I tried to reinstall R, Rstudio, Rtools, but it still didn’t work. Thank you for your help

Error in compileCode(f, code, language = language, verbose = verbose) : 
  sh: line 1: c:/rtools40/mingw64/bin/g++: No such file or directorymake: *** [C:/PROGRA~1/R/R-41~1.3/etc/x64/Makeconf:245: file1dd85c6f45fc.o] Error 127
Error in sink(type = "output") : invalid connection

regards

Windows 10
brms 2.17.0
rstan 2.21.5
R 4.1.3
RStudio 2022.02.2

pkgbuild::has_build_tools(debug = TRUE)
Scanning R CMD config CC…
cc_path:
‘’ does not exist
Scanning path…
Scanning registry…
Found C:/RBuildTools/4.0 for 4.0

This worked for me: