# Warning that I need to install Rtools when I already have it installed

**URL:** <https://discourse.mc-stan.org/t/warning-that-i-need-to-install-rtools-when-i-already-have-it-installed/32723>\
**Category:** RStan\
**Tags:** windows\
**Created:** [September 11, 2023, 2:28pm UTC](https://discourse.mc-stan.org/t/warning-that-i-need-to-install-rtools-when-i-already-have-it-installed/32723 "2023-09-11T14:28:45Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![jd\_c](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jd_c/32/16759_2.png) [@jd\_c](https://discourse.mc-stan.org/u/jd_c)\
**Post date:** [September 11, 2023, 2:28pm UTC](https://discourse.mc-stan.org/t/warning-that-i-need-to-install-rtools-when-i-already-have-it-installed/32723/1 "2023-09-11T14:28:45Z")

</div>

Howdy! I am trying to install rstan on a computer with Windows 10 that is very troublesome due to lots of clamped down security. I have R 4.3.0 and Rtools 4.3 installed. I can only install binaries from a http CRAN repository on this machine. I seem to have successfully installed the new rstan 2.26 from CRAN, but when I ran the example model, I got the following warnings:

```plaintext
WARNING: Rtools is required to build R packages, but no version of Rtools compatible with R 4.3.0 was found. (Only the following incompatible version(s) of Rtools were found: 4.3.5550)

Please download and install Rtools 4.2 from https://cran.r-project.org/bin/windows/Rtools/ or https://www.r-project.org/nosvn/winutf8/ucrt3/.
WARNING: Rtools is required to build R packages, but no version of Rtools compatible with R 4.3.0 was found. (Only the following incompatible version(s) of Rtools were found: 4.3.5550)

Please download and install Rtools 4.2 from https://cran.r-project.org/bin/windows/Rtools/ or https://www.r-project.org/nosvn/winutf8/ucrt3/.
Scanning R CMD config CC...
cc_path: C:/Rtools/mingw_64/bin/gcc 
'C:/Rtools/mingw_64/bin/gcc' does not exist
Scanning path...
ls: C:\rtools43\usr\bin\ls.exe 
gcc_path: C:\rtools43\X86_64~1.POS\bin\gcc.exe 
Scanning registry...
Found C:/rtools43 for 4.3.5550 
WARNING: Rtools is required to build R packages, but no version of Rtools compatible with R 4.3.0 was found. (Only the following incompatible version(s) of Rtools were found: 4.3.5550)

```

I saw [this post](https://discourse.mc-stan.org/t/rstan-installation-troubles/31268/45) that talked about this same warning for Windows 11 users. Unfortunately, I cannot try those solutions, because I don’t have the admin rights to make those changes. Is there any other solution to this problem? Thanks!

---

<div class="post-metadata">

**Author:** ![jonah](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jonah/32/200_2.png) [@jonah](https://discourse.mc-stan.org/u/jonah)\
**Post date:** [September 12, 2023, 3:38pm UTC](https://discourse.mc-stan.org/t/warning-that-i-need-to-install-rtools-when-i-already-have-it-installed/32723/2 "2023-09-12T15:38:49Z")

</div>

I have no idea unfortunately. Does it run ok and you just get these annoying spurious warnings, or are these actually errors (that just happen to say warning instead of error)?

@andrjohns have you seen this before?

---

<div class="post-metadata">

**Author:** ![jd\_c](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jd_c/32/16759_2.png) [@jd\_c](https://discourse.mc-stan.org/u/jd_c)\
**Post date:** [September 12, 2023, 3:42pm UTC](https://discourse.mc-stan.org/t/warning-that-i-need-to-install-rtools-when-i-already-have-it-installed/32723/3 "2023-09-12T15:42:50Z")

</div>

Unfortunately it is an actual error and the model won’t run.

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [September 12, 2023, 3:58pm UTC](https://discourse.mc-stan.org/t/warning-that-i-need-to-install-rtools-when-i-already-have-it-installed/32723/4 "2023-09-12T15:58:56Z")

</div>

What output do you get from:

```r
sessionInfo()
pkgbuild::check_build_tools(debug = TRUE)

```

---

<div class="post-metadata">

**Author:** ![jd\_c](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jd_c/32/16759_2.png) [@jd\_c](https://discourse.mc-stan.org/u/jd_c)\
**Post date:** [September 12, 2023, 4:31pm UTC](https://discourse.mc-stan.org/t/warning-that-i-need-to-install-rtools-when-i-already-have-it-installed/32723/5 "2023-09-12T16:31:05Z")

</div>

```plaintext
> sessionInfo()
R version 4.3.0 (2023-04-21 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: America/Chicago
tzcode source: internal

attached base packages:
[1] stats graphics grDevices utils datasets methods base     

other attached packages:
[1] brms_2.19.0 Rcpp_1.0.10

loaded via a namespace (and not attached):
 [1] tidyselect_1.2.0 dplyr_1.1.2 farver_2.1.1 loo_2.6.0 fastmap_1.1.1 tensorA_0.36.2 shinystan_2.6.0     
 [8] promises_1.2.0.1 shinyjs_2.1.0 digest_0.6.31 mime_0.12 lifecycle_1.0.3 StanHeaders_2.26.27 ellipsis_0.3.2      
[15] processx_3.8.1 magrittr_2.0.3 posterior_1.4.1 compiler_4.3.0 rlang_1.1.1 tools_4.3.0 igraph_1.4.3        
[22] utf8_1.2.3 prettyunits_1.1.1 bridgesampling_1.1-2 htmlwidgets_1.6.2 pkgbuild_1.4.0 plyr_1.8.8 dygraphs_1.1.1.6    
[29] abind_1.4-5 miniUI_0.1.1.1 grid_4.3.0 stats4_4.3.0 fansi_1.0.4 xts_0.13.1 xtable_1.8-4        
[36] colorspace_2.1-0 inline_0.3.19 ggplot2_3.4.2 scales_1.2.1 gtools_3.9.4 cli_3.6.1 mvtnorm_1.1-3       
[43] crayon_1.5.2 generics_0.1.3 RcppParallel_5.1.7 reshape2_1.4.4 rstan_2.26.23 stringr_1.5.0 shinythemes_1.2.0   
[50] bayesplot_1.10.0 parallel_4.3.0 matrixStats_0.63.0 base64enc_0.1-3 vctrs_0.6.2 Matrix_1.5-4 jsonlite_1.8.4      
[57] callr_3.7.3 crosstalk_1.2.0 glue_1.6.2 codetools_0.2-19 ps_1.7.5 DT_0.28 distributional_0.3.2
[64] stringi_1.7.12 gtable_0.3.3 later_1.3.1 QuickJSR_1.0.5 munsell_0.5.0 tibble_3.2.1 colourpicker_1.2.0  
[71] pillar_1.9.0 htmltools_0.5.5 Brobdingnag_1.2-9 R6_2.5.1 shiny_1.7.4 lattice_0.21-8 markdown_1.7        
[78] backports_1.4.1 threejs_0.3.3 httpuv_1.6.11 rstantools_2.3.1 coda_0.19-4 gridExtra_2.3 nlme_3.1-162        
[85] checkmate_2.2.0 zoo_1.8-12 pkgconfig_2.0.3     

> pkgbuild::check_build_tools(debug = TRUE)
Scanning R CMD config CC...
cc_path: C:/Rtools/mingw_64/bin/gcc 
'C:/Rtools/mingw_64/bin/gcc' does not exist
Scanning path...
ls: C:\rtools43\usr\bin\ls.exe 
gcc_path: C:\rtools43\X86_64~1.POS\bin\gcc.exe 
Scanning registry...
Found C:/rtools43 for 4.3.5550 
WARNING: Rtools is required to build R packages, but no version of Rtools compatible with R 4.3.0 was found. (Only the following incompatible version(s) of Rtools were found: 4.3.5550)

Please download and install Rtools 4.2 from https://cran.r-project.org/bin/windows/Rtools/ or https://www.r-project.org/nosvn/winutf8/ucrt3/.
Scanning R CMD config CC...
cc_path: C:/Rtools/mingw_64/bin/gcc 
'C:/Rtools/mingw_64/bin/gcc' does not exist
Scanning path...
ls: C:\rtools43\usr\bin\ls.exe 
gcc_path: C:\rtools43\X86_64~1.POS\bin\gcc.exe 
Scanning registry...
Found C:/rtools43 for 4.3.5550 
WARNING: Rtools is required to build R packages, but no version of Rtools compatible with R 4.3.0 was found. (Only the following incompatible version(s) of Rtools were found: 4.3.5550)

Please download and install Rtools 4.2 from https://cran.r-project.org/bin/windows/Rtools/ or https://www.r-project.org/nosvn/winutf8/ucrt3/.
Error: Could not find tools necessary to compile a package
Call `pkgbuild::check_build_tools(debug = TRUE)` to diagnose the problem.

```

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [September 12, 2023, 4:37pm UTC](https://discourse.mc-stan.org/t/warning-that-i-need-to-install-rtools-when-i-already-have-it-installed/32723/6 "2023-09-12T16:37:56Z")

</div>

Can you update your `pkgbuild` package (the current is 1.4.2) and try again?

---

<div class="post-metadata">

**Author:** ![jd\_c](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jd_c/32/16759_2.png) [@jd\_c](https://discourse.mc-stan.org/u/jd_c)\
**Post date:** [September 12, 2023, 5:00pm UTC](https://discourse.mc-stan.org/t/warning-that-i-need-to-install-rtools-when-i-already-have-it-installed/32723/7 "2023-09-12T17:00:08Z")

</div>

After updating `pkgbuild`, here is the error I get from brms example model now:

```plaintext
> m1 <- brm(age ~ 1, data=kidney, cores=4)
Compiling Stan program...
make cmd is
  make -f "C:/PROGRA~1/R/R-43~1.0/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-43~1.0/share/make/winshlib.mk" -f "C:\Users\MyUserName\OneDrive - Department of Veterans Affairs\Documents/.R/Makevars.win" CXX='$(CXX14) $(CXX14STD)' CXXFLAGS='$(CXX14FLAGS)' CXXPICFLAGS='$(CXX14PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX14LDFLAGS)' SHLIB_LD='$(SHLIB_CXX14LD)' SHLIB="file916c6f951d.dll" WIN=64 TCLBIN= OBJECTS="file916c6f951d.o"

make would use
C:/Rtools/mingw_64/bin/g++ -std=gnu++14 -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG -I"C:/Users/MyUserName/AppData/Local/R/win-library/4.3/Rcpp/include/" -I"C:/Users/MyUserName/AppData/Local/R/win-library/4.3/RcppEigen/include/" -I"C:/Users/MyUserName/AppData/Local/R/win-library/4.3/RcppEigen/include/unsupported" -I"C:/Users/MyUserName/AppData/Local/R/win-library/4.3/BH/include" -I"C:/Users/MyUserName/AppData/Local/R/win-library/4.3/StanHeaders/include/src/" -I"C:/Users/MyUserName/AppData/Local/R/win-library/4.3/StanHeaders/include/" -I"C:/Users/MyUserName/AppData/Local/R/win-library/4.3/RcppParallel/include/" -DRCPP_PARALLEL_USE_TBB=1 -I"C:/Users/MyUserName/AppData/Local/R/win-library/4.3/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DUSE_STANC3 -DSTRICT_R_HEADERS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -include "C:/Users/MyUserName/AppData/Local/R/win-library/4.3/StanHeaders/include/stan/math/prim/fun/Eigen.hpp" -std=c++1y -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -mtune=native -O3 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -c file916c6f951d.cpp -o file916c6f951d.o
if test "zfile916c6f951d.o" != "z"; then \
  if test -e "file916c6f951d-win.def"; then \
    echo C:/Rtools/mingw_64/bin/g++ -shared -s -static-libgcc -o file916c6f951d.dll file916c6f951d-win.def file916c6f951d.o "C:/Users/MyUserName/AppData/Local/R/win-library/4.3/rstan/lib/x64/libStanServices.a" -L"C:/Users/MyUserName/AppData/Local/R/win-library/4.3/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/MyUserName/AppData/Local/R/win-library/4.3/RcppParallel/lib/x64" -ltbb -LC:/Users/MyUserName/AppData/Local/R/win-library/4.3/RcppParallel/lib/x64 -ltbb -ltbbmalloc -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib" -L"C:/PROGRA~1/R/R-43~1.0/bin/x64" -lR ; \
    C:/Rtools/mingw_64/bin/g++ -shared -s -static-libgcc -o file916c6f951d.dll file916c6f951d-win.def file916c6f951d.o "C:/Users/MyUserName/AppData/Local/R/win-library/4.3/rstan/lib/x64/libStanServices.a" -L"C:/Users/MyUserName/AppData/Local/R/win-library/4.3/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/MyUserName/AppData/Local/R/win-library/4.3/RcppParallel/lib/x64" -ltbb -LC:/Users/MyUserName/AppData/Local/R/win-library/4.3/RcppParallel/lib/x64 -ltbb -ltbbmalloc -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib" -L"C:/PROGRA~1/R/R-43~1.0/bin/x64" -lR ; \
  else \
    echo EXPORTS > tmp.def; \
    C:/Rtools/mingw_64/bin/nm file916c6f951d.o | sed -n 's/^.* [BCDRT] / /p' | sed -e '/[.]refptr[.]/d' -e '/[.]weak[.]/d' | sed 's/[^][^]*/"&"/g' >> tmp.def; \
    echo C:/Rtools/mingw_64/bin/g++ -shared -s -static-libgcc -o file916c6f951d.dll tmp.def file916c6f951d.o "C:/Users/MyUserName/AppData/Local/R/win-library/4.3/rstan/lib/x64/libStanServices.a" -L"C:/Users/MyUserName/AppData/Local/R/win-library/4.3/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/MyUserName/AppData/Local/R/win-library/4.3/RcppParallel/lib/x64" -ltbb -LC:/Users/MyUserName/AppData/Local/R/win-library/4.3/RcppParallel/lib/x64 -ltbb -ltbbmalloc -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib" -L"C:/PROGRA~1/R/R-43~1.0/bin/x64" -lR ; \
    C:/Rtools/mingw_64/bin/g++ -shared -s -static-libgcc -o file916c6f951d.dll tmp.def file916c6f951d.o "C:/Users/MyUserName/AppData/Local/R/win-library/4.3/rstan/lib/x64/libStanServices.a" -L"C:/Users/MyUserName/AppData/Local/R/win-library/4.3/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/MyUserName/AppData/Local/R/win-library/4.3/RcppParallel/lib/x64" -ltbb -LC:/Users/MyUserName/AppData/Local/R/win-library/4.3/RcppParallel/lib/x64 -ltbb -ltbbmalloc -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib" -L"C:/PROGRA~1/R/R-43~1.0/bin/x64" -lR ; \
    rm -f tmp.def; \
  fi \
fi
Error in compileCode(f, code, language = language, verbose = verbose) : 
  /bin/sh: line 1: C:/Rtools/mingw_64/bin/g++: No such file or directorymake: *** [C:/PROGRA~1/R/R-43~1.0/etc/x64/Makeconf:272: file916c6f951d.o] Error 127
Error in sink(type = "output") : invalid connection

```

For rstan from the `example(stan_model, package = "rstan", run.dontrun = TRUE)`, I get voluminous output:

```plaintext
> example(stan_model, package = "rstan", run.dontrun = TRUE)

stn_md> stancode <- 'data {real y_mean;} parameters {real y;} model {y ~ normal(y_mean,1);}'

stn_md> mod <- stan_model(model_code = stancode, verbose = TRUE)

TRANSLATING MODEL '' FROM Stan CODE TO C++ CODE NOW.
COMPILING THE C++ CODE FOR MODEL 'anon_model' NOW.
OS: x86_64, mingw32; rstan: 2.26.23; Rcpp: 1.0.10; inline: 0.3.19 
 >> setting environment variables: 
PKG_LIBS = "C:/Users/MyUserName/AppData/Local/R/win-library/4.3/rstan/lib/x64/libStanServices.a" -L"C:/Users/MyUserName/AppData/Local/R/win-library/4.3/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/MyUserName/AppData/Local/R/win-library/4.3/RcppParallel/lib/x64" -ltbb -LC:/Users/MyUserName/AppData/Local/R/win-library/4.3/RcppParallel/lib/x64 -ltbb -ltbbmalloc
PKG_CPPFLAGS = -I"C:/Users/MyUserName/AppData/Local/R/win-library/4.3/Rcpp/include/" -I"C:/Users/MyUserName/AppData/Local/R/win-library/4.3/RcppEigen/include/" -I"C:/Users/MyUserName/AppData/Local/R/win-library/4.3/RcppEigen/include/unsupported" -I"C:/Users/MyUserName/AppData/Local/R/win-library/4.3/BH/include" -I"C:/Users/MyUserName/AppData/Local/R/win-library/4.3/StanHeaders/include/src/" -I"C:/Users/MyUserName/AppData/Local/R/win-library/4.3/StanHeaders/include/" -I"C:/Users/MyUserName/AppData/Local/R/win-library/4.3/RcppParallel/include/" -DRCPP_PARALLEL_USE_TBB=1 -I"C:/Users/MyUserName/AppData/Local/R/win-library/4.3/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DUSE_STANC3 -DSTRICT_R_HEADERS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -include "C:/Users/MyUserName/AppData/Local/R/win-library/4.3/StanHeaders/include/stan/math/prim/fun/Eigen.hpp" -std=c++1y
 >> Program source :

make cmd is
  make -f "C:/PROGRA~1/R/R-43~1.0/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-43~1.0/share/make/winshlib.mk" -f "C:\Users\MyUserName2\OneDrive - Department of Veterans Affairs\Documents/.R/Makevars.win" CXX='$(CXX14) $(CXX14STD)' CXXFLAGS='$(CXX14FLAGS)' CXXPICFLAGS='$(CXX14PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX14LDFLAGS)' SHLIB_LD='$(SHLIB_CXX14LD)' SHLIB="file916cb43dc.dll" WIN=64 TCLBIN= OBJECTS="file916cb43dc.o"

make would use
C:/Rtools/mingw_64/bin/g++ -std=gnu++14 -I"C:/PROGRA~1/R/R-43~1.0/include" -DNDEBUG -I"C:/Users/MyUserName2/AppData/Local/R/win-library/4.3/Rcpp/include/" -I"C:/Users/MyUserName2/AppData/Local/R/win-library/4.3/RcppEigen/include/" -I"C:/Users/MyUserName2/AppData/Local/R/win-library/4.3/RcppEigen/include/unsupported" -I"C:/Users/MyUserName2/AppData/Local/R/win-library/4.3/BH/include" -I"C:/Users/MyUserName2/AppData/Local/R/win-library/4.3/StanHeaders/include/src/" -I"C:/Users/MyUserName2/AppData/Local/R/win-library/4.3/StanHeaders/include/" -I"C:/Users/MyUserName2/AppData/Local/R/win-library/4.3/RcppParallel/include/" -DRCPP_PARALLEL_USE_TBB=1 -I"C:/Users/MyUserName2/AppData/Local/R/win-library/4.3/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DUSE_STANC3 -DSTRICT_R_HEADERS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -include "C:/Users/MyUserName2/AppData/Local/R/win-library/4.3/StanHeaders/include/stan/math/prim/fun/Eigen.hpp" -std=c++1y -I"C:/rtools43/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -mtune=native -O3 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -c file916cb43dc.cpp -o file916cb43dc.o
if test "zfile916cb43dc.o" != "z"; then \
  if test -e "file916cb43dc-win.def"; then \
    echo C:/Rtools/mingw_64/bin/g++ -shared -s -static-libgcc -o file916cb43dc.dll file916cb43dc-win.def file916cb43dc.o "C:/Users/MyUserName2/AppData/Local/R/win-library/4.3/rstan/lib/x64/libStanServices.a" -L"C:/Users/MyUserName2/AppData/Local/R/win-library/4.3/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/MyUserName2/AppData/Local/R/win-library/4.3/RcppParallel/lib/x64" -ltbb -LC:/Users/MyUserName2/AppData/Local/R/win-library/4.3/RcppParallel/lib/x64 -ltbb -ltbbmalloc -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib" -L"C:/PROGRA~1/R/R-43~1.0/bin/x64" -lR ; \
    C:/Rtools/mingw_64/bin/g++ -shared -s -static-libgcc -o file916cb43dc.dll file916cb43dc-win.def file916cb43dc.o "C:/Users/MyUserName2/AppData/Local/R/win-library/4.3/rstan/lib/x64/libStanServices.a" -L"C:/Users/MyUserName2/AppData/Local/R/win-library/4.3/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/MyUserName2/AppData/Local/R/win-library/4.3/RcppParallel/lib/x64" -ltbb -LC:/Users/MyUserName2/AppData/Local/R/win-library/4.3/RcppParallel/lib/x64 -ltbb -ltbbmalloc -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib" -L"C:/PROGRA~1/R/R-43~1.0/bin/x64" -lR ; \
  else \
    echo EXPORTS > tmp.def; \
    C:/Rtools/mingw_64/bin/nm file916cb43dc.o | sed -n 's/^.* [BCDRT] / /p' | sed -e '/[.]refptr[.]/d' -e '/[.]weak[.]/d' | sed 's/[^][^]*/"&"/g' >> tmp.def; \
    echo C:/Rtools/mingw_64/bin/g++ -shared -s -static-libgcc -o file916cb43dc.dll tmp.def file916cb43dc.o "C:/Users/MyUserName2/AppData/Local/R/win-library/4.3/rstan/lib/x64/libStanServices.a" -L"C:/Users/MyUserName2/AppData/Local/R/win-library/4.3/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/MyUserName2/AppData/Local/R/win-library/4.3/RcppParallel/lib/x64" -ltbb -LC:/Users/MyUserName2/AppData/Local/R/win-library/4.3/RcppParallel/lib/x64 -ltbb -ltbbmalloc -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib" -L"C:/PROGRA~1/R/R-43~1.0/bin/x64" -lR ; \
    C:/Rtools/mingw_64/bin/g++ -shared -s -static-libgcc -o file916cb43dc.dll tmp.def file916cb43dc.o "C:/Users/MyUserName2/AppData/Local/R/win-library/4.3/rstan/lib/x64/libStanServices.a" -L"C:/Users/MyUserName2/AppData/Local/R/win-library/4.3/StanHeaders/libs/x64" -lStanHeaders -L"C:/Users/MyUserName2/AppData/Local/R/win-library/4.3/RcppParallel/lib/x64" -ltbb -LC:/Users/MyUserName2/AppData/Local/R/win-library/4.3/RcppParallel/lib/x64 -ltbb -ltbbmalloc -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib/x64" -L"C:/rtools43/x86_64-w64-mingw32.static.posix/lib" -L"C:/PROGRA~1/R/R-43~1.0/bin/x64" -lR ; \
    rm -f tmp.def; \
  fi \
fi

ERROR(s) during compilation: source code errors or compiler configuration errors!

```

I only pasted in the very first part of that output, because I got an error from the forum that it was too many characters.

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [September 12, 2023, 5:05pm UTC](https://discourse.mc-stan.org/t/warning-that-i-need-to-install-rtools-when-i-already-have-it-installed/32723/8 "2023-09-12T17:05:14Z")

</div>

The key part of the error is here: `C:/Rtools/mingw_64/bin/g++`.

It looks like you might be specifying a particular rtools path that is causing these failures.

What output do you get from:

```r
Sys.getenv("BINPREF")
Sys.getenv("PATH")
readLines("~/.Renviron")
readLines("~/.Rprofile")

```

---

<div class="post-metadata">

**Author:** ![jd\_c](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jd_c/32/16759_2.png) [@jd\_c](https://discourse.mc-stan.org/u/jd_c)\
**Post date:** [September 12, 2023, 5:09pm UTC](https://discourse.mc-stan.org/t/warning-that-i-need-to-install-rtools-when-i-already-have-it-installed/32723/9 "2023-09-12T17:09:37Z")

</div>

```plaintext
> Sys.getenv("BINPREF")
[1] "C:/Rtools/mingw_$(WIN)/bin/"
> Sys.getenv("PATH")
[1] "C:\\rtools43\\x86_64-w64-mingw32.static.posix\\bin;C:\\rtools43\\usr\\bin;C:\\Rtools\\bin;C:\\Program Files (x86)\\vista\\Imaging;C:\\Program Files (x86)\\Micro Focus\\Reflection;C:\\Program Files\\Micro Focus\\Reflection;C:\\Windows\\System32;C:\\Windows;C:\\Windows\\System32\\wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0;C:\\Windows\\System32\\OpenSSH;C:\\Program Files\\1E\\Client\\Extensibility\\NomadBranch;C:\\Program Files (x86)\\HID Global\\ActivClient;C:\\Program Files\\HID Global\\ActivClient;C:\\Program Files\\SafeNet\\Authentication\\SAC\\x64;C:\\Program Files\\SafeNet\\Authentication\\SAC\\x32;C:\\Program Files\\dotnet;C:\\Program Files\\McAfee\\Solidcore\\Tools\\GatherInfo;C:\\Program Files\\McAfee\\Solidcore\\Tools\\ScAnalyzer;C:\\Program Files\\McAfee\\Solidcore;C:\\Program Files\\McAfee\\Solidcore\\Tools\\ScGetCerts;C:\\Program Files\\PolicyPak;C:\\Program Files\\PowerShell\\7;C:\\Users\\MyUserName2\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\MyUserName2\\AppData\\Local\\Programs\\Git\\cmd"
> readLines("~/.Renviron")
[1] "PATH=\"C:/Rtools/bin;${PATH}\""
> readLines("~/.Rprofile")
[1] "Sys.setenv(BINPREF = \"C:/Rtools/mingw_$(WIN)/bin/\")"

```

---

<div class="post-metadata">

**Author:** ![andrjohns](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/andrjohns/32/15297_2.png) [@andrjohns](https://discourse.mc-stan.org/u/andrjohns)\
**Post date:** [September 12, 2023, 5:11pm UTC](https://discourse.mc-stan.org/t/warning-that-i-need-to-install-rtools-when-i-already-have-it-installed/32723/10 "2023-09-12T17:11:13Z")

</div>

Yep, that’s the culprit. You’re instructing R to look for the RTools toolchain & compilers in the old R3.x folders.

If you delete the `.Renviron` and `.Rprofile` files in your home directory, and then restart R, you should be fine

---

<div class="post-metadata">

**Author:** ![jd\_c](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jd_c/32/16759_2.png) [@jd\_c](https://discourse.mc-stan.org/u/jd_c)\
**Post date:** [September 12, 2023, 5:34pm UTC](https://discourse.mc-stan.org/t/warning-that-i-need-to-install-rtools-when-i-already-have-it-installed/32723/11 "2023-09-12T17:34:36Z")

</div>

That did the trick! Thanks!!! And, I found the culprit - OneDrive. Our organization recently introduced OneDrive in a manner that basically scrapes everything off of your Documents, Desktop, etc, then saves it to the cloud, and then puts it onto every other computer in the organization that you log in to. Pretty ridiculous. So, I use a much older version of R on another computer, but OneDrive transferred the `.Renviron` and `.Rprofile` files from that older computer onto this other computer, making it look for RTools in folders that were never even on this machine.

It seems for the solution to the OP, installing an updated `pkgbuild` did the trick, as I didn’t see that particular error again. Maybe I should mark that as the solution? (since there were multiple problems here).

One last question - by deleting `.Renviron` and `.Rprofile` OneDrive deletes it off of the old computer, which I assume needs it. I just checked, and that computer appears to still run brms and rstan models just fine, but now it throws an additional error: `Warning message: In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) : '-E' not found`  
I assume that is safe to ignore? It has always thrown `Warning message: In system(paste(cmd, "-n")) : 'make' not found` which also doesn’t appear to affect sampling.

---

<div class="post-metadata">

**Author:** ![jonah](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jonah/32/200_2.png) [@jonah](https://discourse.mc-stan.org/u/jonah)\
**Post date:** [September 12, 2023, 5:41pm UTC](https://discourse.mc-stan.org/t/warning-that-i-need-to-install-rtools-when-i-already-have-it-installed/32723/12 "2023-09-12T17:41:30Z")

</div>

I think it’s safe to ignore those other warnings.

Lots of people have been running into issues related to OneDrive (both with RStan and CmdStanR). It seems to be a consistent source of problems.

Thanks @andrjohns for figuring this out!

---

<div class="post-metadata">

**Author:** ![jd\_c](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jd_c/32/16759_2.png) [@jd\_c](https://discourse.mc-stan.org/u/jd_c)\
**Post date:** [September 12, 2023, 6:20pm UTC](https://discourse.mc-stan.org/t/warning-that-i-need-to-install-rtools-when-i-already-have-it-installed/32723/13 "2023-09-12T18:20:10Z")

</div>

@andrjohns and @jonah I really appreciate all of the help on this!

---

<div class="post-metadata">

**Author:** ![jonah](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jonah/32/200_2.png) [@jonah](https://discourse.mc-stan.org/u/jonah)\
**Post date:** [September 12, 2023, 7:23pm UTC](https://discourse.mc-stan.org/t/warning-that-i-need-to-install-rtools-when-i-already-have-it-installed/32723/14 "2023-09-12T19:23:40Z")

</div>

> [@jd\_c](#):
>
> I really appreciate all of the help on this!

We really appreciate that you help answer a lot of questions here on the forum!

---

<div class="post-metadata">

**Author:** ![rensdenheeten](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/rensdenheeten/32/18508_2.png) [@rensdenheeten](https://discourse.mc-stan.org/u/rensdenheeten)\
**Post date:** [May 17, 2024, 2:27pm UTC](https://discourse.mc-stan.org/t/warning-that-i-need-to-install-rtools-when-i-already-have-it-installed/32723/15 "2024-05-17T14:27:01Z")

</div>

I do have a similar problem and don’t know how to fix it. My error in R is as follows:

g++ -std=gnu++17 -I"C:/PROGRA~1/R/R-44~1.0/include" -DNDEBUG -I…/inst/include -fopenmp -I"C:/Users/rens/AppData/Local/R/win-library/4.4/Rcpp/include" -I"C:/Users/rens/AppData/Local/R/win-library/4.4/RcppArmadillo/include" -I"C:/Users/rens/OneDrive/DOCUME~1/uni/BACHEL~1/HHK-IJ~2" -I"c:/rtools44/x86\_64-w64-mingw32.static.posix/include" -O2 -Wall -mfpmath=sse -msse2 -mstackrealign -c kf.cpp -o kf.o  
/bin/sh: line 1: g++: command not found  
make: \*\*\* [C:/PROGRA~1/R/R-44~1.0/etc/x64/Makeconf:296: kf.o] Error 127  
Error in sourceCpp(“kf.cpp”) : Error 1 occurred building shared library.  
trying URL ‘[https://cran.rstudio.com/bin/windows/Rtools/rtools42/files/rtools42-5355-5357.exe](https://cran.rstudio.com/bin/windows/Rtools/rtools42/files/rtools42-5355-5357.exe)’  
Content type ‘application/x-msdownload’ length 482123824 bytes (459.8 MB)  
downloaded 459.8 MB

I do have the RBuildTool installed and it did run before. However the only changes I made is that now I use a newer R version and synchronized some files to my onedrive.
