Error in compileCode & invalid connection

Short summary of the problem
When I run the following code:
fit = stan(“normal_mean.stan”,data=stan_data,chains = 1,iter=10^4)
I obtain the following error message:

Error in compileCode(f, code, language = language, verbose = verbose) :
from C:/Users/Willem/Documents/R/win-library/3.6/StanHeaders/include/src/stan/model/model_header.hpp:4, from file1e7c7c9b298e.cpp:14:C:/Users/Willem/Documents/R/win-library/3.6/StanHeaders/include/stan/math/rev/core/set_zero_all_adjoints.hpp:14:13: warning: ‘void stan::math::set_zero_all_adjoints()’ defined but not used [-Wunused-function] static void set_zero_all_adjoints() { ^make: *** [C:/PROGRA~1/R/R-36~1.3/etc/x64/Makeconf:215: file1e7c7c9b298e.o] Error 1
In addition: Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
‘-E’ not found
Error in sink(type = “output”) : invalid connection

I use Windows 10 and for as far as I know, I have installed all the required packages and Rtools.

I can’t find out what the problem is and all the given solutions seem not to work for me unfortunately. Thank you in advance for your reaction.

I think I have a similar problem. I ran the following code:
fit<- stan(file=‘EU.stan’,
data=list(N=N,nsubj=nsubj,subjs=subjs,choices=choices,x1a=x1a,x2a=x2a,x3a=x3a,x4a=x4a,
x1b=x1b,x2b=x2b,x3b=x3b,x4b=x4b,p1a=p1a,p2a=p2a,p3a=p3a,p4a=p4a,p1b=p1b,p2b=p2b,p3b=p3b,p4b=p4b,sid=sid),
warmup=5,
chains=4,
iter=100,
init_r=1,
verbose=FALSE)

I then got the following error:
Error in compileCode(f, code, language = language, verbose = verbose) :
C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: file327c377a3dae.o:file327c377a3dae.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: file327c377a3dae.o:file327c377a3dae.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: file327c377a3dae.o:file327c377a3dae.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: file327c377a3dae.o:file327c377a3dae.cpp:(.text$_ZN3tbb10interface
Error in sink(type = “output”) : invalid connection

Can someone please advise. Thanks in advance!

We’re having some compatibility issues with R4.2 and the CRAN rstan, can I get you to restart your R session and then install the preview of the next rstan version using:

remove.packages(c("rstan","StanHeaders"))
install.packages("StanHeaders", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
1 Like

Thank you! Looks like it is working now.

Hi,
I’m using R 4.3.1 and Windows 11.
When I ran the access codes for the preview of the rstan version, I got the errors below:
unable to access index for repository https://mc-stan.org/r-packages/bin/windows/contrib/4.3:
cannot open URL ‘https://mc-stan.org/r-packages/bin/windows/contrib/4.3/PACKAGES

How can I access the link???

Instead, I got them installed by these:
install.packages(“StanHeaders”,
repos = c(“https://cran.rstudio.com/bin/windows/contrib/4.3/StanHeaders_2.26.27.zip”,
getOption(“repos”)))
install.packages(“rstan”,
repos = c(“https://cran.rstudio.com/bin/windows/contrib/4.3/rstan_2.21.8.zip.zip”,
getOption(“repos”)))

Then, when running a stan model, it threw the Error in compile Code:
Error in compileCode(f, code, language = language, verbose = verbose) :
C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: file310010f15770.o:file310010f15770.cpp:(.text$_ZN3tbb8internal26task_scheduler_observer_v3D0Ev[_ZN3tbb8internal26task_scheduler_observer_v3D0Ev]+0x1c): undefined reference to tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: file310010f15770.o:file310010f15770.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[_ZN3tbb10interface623task_scheduler_observerD1Ev]+0x1c): undefined reference to tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: file310010f15770.o:file310010f15770.cpp:(.text$_ZN3tbb10interface623task_scheduler_observerD1Ev[_ZN3tbb10interface623task_scheduler_observerD1Ev]+0x37): undefined reference to `tbb::internal::task_scheduler_observer_v3::observe(bool)'C:\rtools43\x86_64-w64-mingw32.static.posix\bin/ld.exe: file310010f15770.o:file310010f15770.cpp:(.text$_ZN3tbb10interface
In addition: Warning message:
In readLines(file.path(makevar_files)) :
incomplete final line found on ‘C:/Users/jwart/Documents/.R/Makevars’