Problem running stan() function. October 2022. R version 4.2.1. Windows 10

I am unable to run the stan function from the rstan package. I get the next error:

*Error in compileCode(f, code, language = language, verbose = verbose) : *
*  C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: file425012bf77f2.o:file425012bf77f2.cpp:(.text$_ZN3tbb8internal26task_scheduler_observer_v3D0Ev[_ZN3tbb8internal26task_scheduler_observer_v3D0Ev]+0x1d): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: file425012bf77f2.o:file425012bf77f2.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[_ZN3tbb10interface623task_scheduler_observerD1Ev]+0x1d): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: file425012bf77f2.o:file425012bf77f2.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[_ZN3tbb10interface623task_scheduler_observerD1Ev]+0x3a): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: file425012bf77f2.o:file425012bf77f2.cpp:(.text$_ZN3tbb10interface*
*Error in sink(type = "output") : invalid connection*

I already went through some threads from this site and still haven’t been able to run the function. Among the things I have tried, I have:

  • Restarted the R session and then reinstalled rtools4.2

  • Uninstalled and reinstalled rstan

  • Installed rstan and StanHeaders from source and restarted the R session.

My session info is stated below.
R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22621)

I would appreaciate any help immensely.

@andrjohns I am sorry to be tagging you directly, but I’ve seen you are a principal solver of this precise problem.

See the RStan Getting Started Guide

1 Like

I’m laughing at how dumb I was for not finding that out.
Thanks a lot. Have a great day.