# Problem running rstan with R 4.0.2

**URL:** <https://discourse.mc-stan.org/t/problem-running-rstan-with-r-4-0-2/17257>\
**Category:** RStan\
**Tags:** rstan\
**Created:** [August 5, 2020, 5:40pm UTC](https://discourse.mc-stan.org/t/problem-running-rstan-with-r-4-0-2/17257 "2020-08-05T17:40:46Z")\
**Posts on this page:** 10\
**Page:** 2

<div class="post-metadata">

**Author:** ![banbh](https://avatars.discourse-cdn.com/v4/letter/b/919ad9/32.png) [@banbh](https://discourse.mc-stan.org/u/banbh)\
**Post date:** [August 9, 2020, 2:06am UTC](https://discourse.mc-stan.org/t/problem-running-rstan-with-r-4-0-2/17257/21 "2020-08-09T02:06:40Z")

</div>

I am encountering the same warning as the OP in this thread (namely “‘C:/rtools40/usr/mingw\_/bin/g++’ not found”). Like the OP I don’t have a directory called `C:/rtools40/usr/mingw_/bin` (although I do have `C:\rtools40\mingw64\bin`). However, I notice that [RStan Getting Started · stan-dev/rstan Wiki · GitHub](https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started) says:

> On Windows you may get a warning about `g++` not being found but this appears to be harmless.

I assume this refers to the warning we are getting. Is that right?

In my case it does seem to be harmless, although I have not kept timings, and therefore I don’t know whether it has affected compilation times, or sampling times.

Update: The combined thread on these kinds of issues has the definitive reply (I think) to this warning: [Rstan on Windows - #123 by bgoodri](https://discourse.mc-stan.org/t/rstan-on-windows/16673/123)

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [August 9, 2020, 3:54am UTC](https://discourse.mc-stan.org/t/problem-running-rstan-with-r-4-0-2/17257/22 "2020-08-09T03:54:06Z")

</div>

It is harmless unless you have `#include` statements in your Stan program.

---

<div class="post-metadata">

**Author:** ![Antoine](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@Antoine](https://discourse.mc-stan.org/u/Antoine)\
**Post date:** [August 10, 2020, 10:51am UTC](https://discourse.mc-stan.org/t/problem-running-rstan-with-r-4-0-2/17257/23 "2020-08-10T10:51:27Z")

</div>

I ran this code and I get these errors:

```
> file <- file.path(cmdstan_path(), "examples", "bernoulli", "bernoulli.stan")
> mod <- cmdstan_model(file)
Compiling Stan program...
Informationÿ: impossible de trouver des fichiers pour le(s) modŠle(s) sp‚cifi‚(s).
Informationÿ: impossible de trouver des fichiers pour le(s) modŠle(s) sp‚cifi‚(s).
ar: création de stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_nvecserial.a
ar: création de stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_cvodes.a
ar: création de stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_idas.a
ar: création de stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_kinsol.a
C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb_2019_U8/build/Makefile.tbb:28: CONFIG: cfg=release arch=intel64 compiler=gcc target=windows runtime=mingw8.3.0
task.o: duplicate section `.rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]' has different size
arena.o: duplicate section `.rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]' has different size
scheduler.o: duplicate section `.rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]' has different size
C:/Program Files/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find C:/Program: No such file or directory
C:/Program Files/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find Files/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/lib/../lib/default-manifest.o: No such file or directory
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe: *** [make/program:62: C:/Users/Antoine/AppData/Local/Temp/RtmpstbwaD/model-21a02d866116.exe] Error 1
Erreur : An error occured during compilation! See the message above for more information.

```

If it says “cannot find C:/Program: No such file in directory”, isn’t that an indication that the space in “Program Files” causes problems?

Concerning the “g++” warning message when running stan(), I confirm that it does not seem to prevent anything, I was able to run multiple (simple) models without issues.

Cheers

---

<div class="post-metadata">

**Author:** ![rok\_cesnovar](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@rok\_cesnovar](https://discourse.mc-stan.org/u/rok_cesnovar)\
**Post date:** [August 10, 2020, 10:56am UTC](https://discourse.mc-stan.org/t/problem-running-rstan-with-r-4-0-2/17257/24 "2020-08-10T10:56:49Z")

</div>

Can you run the following:

```
writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron")

```

and restart R or Rstudio and then run:

```
rebuild_cmdstan(cores = 4)

```

---

<div class="post-metadata">

**Author:** ![Antoine](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@Antoine](https://discourse.mc-stan.org/u/Antoine)\
**Post date:** [August 10, 2020, 11:17am UTC](https://discourse.mc-stan.org/t/problem-running-rstan-with-r-4-0-2/17257/25 "2020-08-10T11:17:37Z")

</div>

It’s an awful lot of lines that I can’t all paste here, so I’m only pasting the first part and chunks with red messages:

```
library(cmdstanr)
This is cmdstanr version 0.1.1
- Online documentation and vignettes at mc-stan.org/cmdstanr
- CmdStan path set to: C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0
- Use set_cmdstan_path() to change the path
> rebuild_cmdstan(cores = 4)
Informationÿ: impossible de trouver des fichiers pour le(s) modŠle(s) sp‚cifi‚(s).
rm -f -r test
rm -f 
rm -f 
rm -f 
rm -f 
  removing dependency files
rm -f src/cmdstan/main.d stan//src/stan/model/model_header.d
rm -f   
rm -f   
  cleaning sundials targets
rm -f stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_cvodes.a stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_idas.a stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_kinsol.a stan/lib/stan_math/lib/sundials_5.2.0/lib/libsundials_nvecserial.a stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodea.o stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodea_io.o stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodes.o stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodes_bandpre.o stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodes_bbdpre.o stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodes_diag.o stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodes_direct.o stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodes_io.o stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodes_ls.o stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodes_nls.o stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodes_nls_sim.o stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodes_nls_stg.o stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodes_nls_stg1.o stan/lib/stan_math/lib/sundials_5.2.0/src/cvodes/cvodes_spils.o stan/lib/stan_math/lib/sundials_5.2.0/src/idas/idaa.o stan/lib/stan_math/lib/sundials_5.2.0/src/idas/idaa_io.o stan/lib/stan_math/lib/sundials_5.2.0/src/idas/idas.o stan/lib/stan_math/lib/sundials_5.2.0/src/idas/idas_bbdpre.o stan/lib/stan_math/lib/sundials_5.2.0/src/idas/idas_direct.o stan/lib/stan_math/lib/sundials_5.2.0/src/idas/idas_ic.o stan/lib/stan_math/lib/sundials_5.2.0/src/idas/idas_io.o stan/lib/stan_math/lib/sundials_5.2.0/src/idas/idas_ls.o stan/lib/stan_math/lib/sundials_5.2.0/src/idas/idas_nls.o stan/lib/stan_math/lib/sundials_5.2.0/src/idas/idas_nls_sim.o stan/lib/stan_math/lib/sundials_5.2.0/src/idas/idas_nls_stg.o stan/lib/stan_math/lib/sundials_5.2.0/src/idas/idas_spils.o stan/lib/stan_math/lib/sundials_5.2.0/src/kinsol/kinsol.o stan/lib/stan_math/lib/sundials_5.2.0/src/kinsol/kinsol_bbdpre.o stan/lib/stan_math/lib/sundials_5.2.0/src/kinsol/kinsol_direct.o stan/lib/stan_math/lib/sundials_5.2.0/src/kinsol/kinsol_io.o stan/lib/stan_math/lib/sundials_5.2.0/src/kinsol/kinsol_ls.o stan/lib/stan_math/lib/sundials_5.2.0/src/kinsol/kinsol_spils.o stan/lib/stan_math/lib/sundials_5.2.0/src/nvector/serial/nvector_serial.o stan/lib/stan_math/lib/sundials_5.2.0/src/sundials/sundials_band.o stan/lib/stan_math/lib/sundials_5.2.0/src/sundials/sundials_dense.o stan/lib/stan_math/lib/sundials_5.2.0/src/sundials/sundials_direct.o stan/lib/stan_math/lib/sundials_5.2.0/src/sundials/sundials_futils.o stan/lib/stan_math/lib/sundials_5.2.0/src/sundials/sundials_iterative.o stan/lib/stan_math/lib/sundials_5.2.0/src/sundials/sundials_linearsolver.o stan/lib/stan_math/lib/sundials_5.2.0/src/sundials/sundials_math.o stan/lib/stan_math/lib/sundials_5.2.0/src/sundials/sundials_matrix.o stan/lib/stan_math/lib/sundials_5.2.0/src/sundials/sundials_nonlinearsolver.o stan/lib/stan_math/lib/sundials_5.2.0/src/sundials/sundials_nvector.o stan/lib/stan_math/lib/sundials_5.2.0/src/sundials/sundials_nvector_senswrapper.o stan/lib/stan_math/lib/sundials_5.2.0/src/sundials/sundials_version.o stan/lib/stan_math/lib/sundials_5.2.0/src/sunlinsol/band/sunlinsol_band.o stan/lib/stan_math/lib/sundials_5.2.0/src/sunlinsol/dense/sunlinsol_dense.o stan/lib/stan_math/lib/sundials_5.2.0/src/sunmatrix/band/sunmatrix_band.o stan/lib/stan_math/lib/sundials_5.2.0/src/sunmatrix/dense/sunmatrix_dense.o stan/lib/stan_math/lib/sundials_5.2.0/src/sunnonlinsol/fixedpoint/sunnonlinsol_fixedpoint.o stan/lib/stan_math/lib/sundials_5.2.0/src/sunnonlinsol/newton/sunnonlinsol_newton.o
  cleaning Intel TBB targets
rm -f -rf stan/lib/stan_math/lib/tbb
rm -f bin/stanc.exe bin/stanc2.exe bin/stansummary.exe bin/print.exe bin/diagnose.exe
rm -f -r src/cmdstan/main*.o bin/cmdstan
rm -f stan/src/stan/model/model_header.hpp.gch
rm -f examples/bernoulli/bernoulli.exe examples/bernoulli/bernoulli.o examples/bernoulli/bernoulli.d examples/bernoulli/bernoulli.hpp
rm -f -r stan/lib/stan_math/lib/boost_1.72.0/stage/lib stan/lib/stan_math/lib/boost_1.72.0/bootstrap.log
Informationÿ: impossible de trouver des fichiers pour le(s) modŠle(s) sp‚cifi‚(s).
cp bin/windows-stanc bin/stanc.exe
cd stan/lib/stan_math/lib/boost_1.72.0; ./bootstrap.bat gcc
.
.
.

g++ -c -MMD -O2 -DUSE_WINTHREAD -D_WIN32_WINNT=0x0502 -DMINGW_HAS_SECURE_API=1 -D __MSVCRT_VERSION__ =0x0700 -msse -mthreads -m64 -mrtm -fno-rtti -fno-exceptions -D__TBBMALLOC_BUILD=1 -Wno-parentheses -Wno-uninitialized -Wno-non-virtual-dtor -flifetime-dse=1 -I../tbb_2019_U8/src -I../tbb_2019_U8/src/rml/include -I../tbb_2019_U8/include -I../tbb_2019_U8/src/tbbmalloc -I../tbb_2019_U8/src/tbbmalloc -I. ../tbb_2019_U8/src/tbbmalloc/frontend.cpp
gcc -o tbbmalloc.dll backend.o large_objects.o backref.o tbbmalloc.o itt_notify_malloc.o frontend.o -lpsapi -shared -m64 -Wl,-L,"C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb" -Wl,--version-script,tbbmalloc.def
C:/Program Files/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find C:/Program: No such file or directory
C:/Program Files/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find Files/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/lib/../lib/default-manifest.o: No such file or directory
collect2.exe: error: ld returned 1 exit status
g++ -o tbbmalloc_proxy.dll proxy.o tbb_function_replacement.o -lpsapi tbbmalloc.dll -shared -m64 -Wl,-L,"C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb"
Fichier introuvable

Failed to build Boost.Build engine.
Please consult bootstrap.log for further diagnostics.

mingw32-make[1]: Leaving directory 'C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb'
mingw32-make.exe: *** [make/command:35: stan/lib/stan_math/lib/boost_1.72.0/stage/lib/libboost_program_options*.a] Error 1
mingw32-make.exe: *** Waiting for unfinished jobs....
touch stan/lib/stan_math/lib/tbb/version_tbb_2019_U8
tbb_root="../tbb_2019_U8" CXX="g++" CC="gcc" LDFLAGS='-Wl,-L,"C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb"' mingw32-make.exe -C "stan/lib/stan_math/lib/tbb" -r -f "C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb_2019_U8/build/Makefile.tbb" compiler=gcc cfg=release stdver=c++1y
mingw32-make[1]: Entering directory 'C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb'
C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb_2019_U8/build/Makefile.tbb:28: CONFIG: cfg=release arch=intel64 compiler=gcc target=windows runtime=mingw8.3.0
g++ -o concurrent_hash_map.o -c -MMD -O2 -DUSE_WINTHREAD -D_WIN32_WINNT=0x0502 -DMINGW_HAS_SECURE_API=1 -D __MSVCRT_VERSION__ =0x0700 -msse -mthreads -m64 -mrtm -flifetime-dse=1 -D__TBB_BUILD=1 -Wall -Wno-parentheses -Wno-uninitialized -Wno-non-virtual-dtor -std=c++1y -I../tbb_2019_U8/src -I../tbb_2019_U8/src/rml/include -I../tbb_2019_U8/include ../tbb_2019_U8/src/tbb/concurrent_hash_map.cpp
.
.
.
task.o: duplicate section `.rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]' has different size
arena.o: duplicate section `.rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]' has different size
scheduler.o: duplicate section `.rdata$_ZTIN3tbb4taskE[_ZTIN3tbb4taskE]' has different size
mingw32-make[1]: Leaving directory 'C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb'

```

In line 7, it says “Information: Unable to find files for the specified models”. It has weird characters in it, but that is what I think it says.  
In this chunk, “Fichier introuvable” means “Unable to find file”:

```
g++ -o tbbmalloc_proxy.dll proxy.o tbb_function_replacement.o -lpsapi tbbmalloc.dll -shared -m64 -Wl,-L,"C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb"
Fichier introuvable

```

Again, sorry for the French.

I re-ran the example model and I get the same error as before.

---

<div class="post-metadata">

**Author:** ![rok\_cesnovar](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@rok\_cesnovar](https://discourse.mc-stan.org/u/rok_cesnovar)\
**Post date:** [August 10, 2020, 11:20am UTC](https://discourse.mc-stan.org/t/problem-running-rstan-with-r-4-0-2/17257/26 "2020-08-10T11:20:59Z")

</div>

In this case the space in Program Files indeed the issue. Can you reinstall it to the default location and rerun this line afterwards

```
writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron")

```

and then try again.

---

<div class="post-metadata">

**Author:** ![Antoine](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@Antoine](https://discourse.mc-stan.org/u/Antoine)\
**Post date:** [August 10, 2020, 12:16pm UTC](https://discourse.mc-stan.org/t/problem-running-rstan-with-r-4-0-2/17257/27 "2020-08-10T12:16:14Z")

</div>

Seemed to have worked smoothly!

At the end of running rebuild\_cmdstan(), it says

```
NOTE: Please add C:/Users/Antoine/Documents/.cmdstanr/cmdstan-2.24.0/stan/lib/stan_math/lib/tbb to your PATH variable.
You may call mingw32-make install-tbb to automatically update your user configuration.

```

I assume

```
writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con = "~/.Renviron")

```

took care of that?

@rok_cesnovar, @bgoodri, @jonah, @stevebronder Thank you all very much for your help with my relatively trivial issues, I appreciate it!  
Cheers

---

<div class="post-metadata">

**Author:** ![rok\_cesnovar](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@rok\_cesnovar](https://discourse.mc-stan.org/u/rok_cesnovar)\
**Post date:** [August 10, 2020, 12:24pm UTC](https://discourse.mc-stan.org/t/problem-running-rstan-with-r-4-0-2/17257/28 "2020-08-10T12:24:33Z")

</div>

Not a problem at all, it was not your fault. You can ignore the above warning, this is printed on install, but cmdstanr handles that automatically.

Cheers

---

<div class="post-metadata">

**Author:** ![Meow](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/meow/32/5339_2.png) [@Meow](https://discourse.mc-stan.org/u/Meow)\
**Post date:** [August 15, 2020, 2:06am UTC](https://discourse.mc-stan.org/t/problem-running-rstan-with-r-4-0-2/17257/29 "2020-08-15T02:06:22Z")

</div>

When I installed the newest `rstan`, I seem to have this error:

```
> schools_dat <- list(J = 8, 
+ y = c(28, 8, -3, 7, -1, 1, 18, 12),
+ sigma = c(15, 10, 16, 11, 9, 11, 10, 18))
> fit <- stan(file = 'C:\\schools.stan', data = schools_dat)
Error in withr::set_makevars(new, path, state, assignment = assignment) : 
  Multiple results for CXX14FLAGS found, something is wrong.FALSE
In addition: Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
  'C:/Rtools/mingw_/bin/g++' not found

```

---

<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:** [August 15, 2020, 4:43am UTC](https://discourse.mc-stan.org/t/problem-running-rstan-with-r-4-0-2/17257/30 "2020-08-15T04:43:42Z")

</div>

> [@Meow](#):
>
> `Multiple results for CXX14FLAGS found, something is wrong.`

There must be multiple CXX14FLAGS entries in your Makevars.win or Makevars file. What comes up if you check those files like this?

```no-highlight
file.edit(file.path(Sys.getenv("HOME"), ".R", "Makevars.win"))
file.edit(file.path(Sys.getenv("HOME"), ".R", "Makevars"))

```

[Previous page](https://discourse.mc-stan.org/t/problem-running-rstan-with-r-4-0-2/17257.md?page=1)
