issue while Using 'Rstan' Package in R

I am using Rstudio 1.3.959 R for windows 4.0.2 and Rtools 4.0 . Facing issue while trying to use rstan package.

when running the below sample code
scode <- "
data {
int y;
int n;

parameters {
real<lower=0, upper=1> pi;

model {
pi ~ beta(0.5, 0.5);
y ~ binomial(n, pi);
sfit1 <- stan(model_code = scode, data=list(y=5, n=20))

I am getting the below error message.

The NEXT version of Stan will not be able to pre-process your Stan program.
Please open an issue at
if you can share or at least describe your Stan program. This will help ensure that Stan
continues to work on your Stan programs in the future. Thank you!
This message can be avoided by wrapping your function call inside suppressMessages().
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: file45286876c5a.o:file45286876c5a.cpp:(.text+0x71c): undefined reference to tbb::internal::task_scheduler_observer_v3::observe(bool)' C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: file45286876c5a.o:file45286876c5a.cpp:(.text+0x1397): undefined reference to rstan::stan_fit::stan_fit(SEXPREC*, int)'
C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: file45286876c5a.o:file45286876c5a.cpp:(.text+0x75e): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'
C:/rtools40/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: file45286876c5a.o:file45286876c5a.cpp:(.text$_ZN3tbb8internal26task_scheduler_observer_v3D1Ev[_ZN3tbb8internal26task_scheduler_observe
In addition: Warning message:
In file.remove(c(unprocessed, processed)) :
cannot remove file 'C:\Users*\AppData\Local\Temp\1\RtmpMPVjAM\file452876186a62.stan', reason 'No such file or directory'
Error in sink(type = "output") : invalid connection"


It seems the error message tells you to submit this question to the Rstan's GitHub page, so I should do that rather than here :slight_smile:

Also, if you like us to help debugging code, please provide us with a reprex next time. A reprex consists of the minimal code and data needed to recreate the issue/question you're having. You can find instructions how to build and share one here:


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.