2

I am new to posting in the stack overflow community so I am sorry if this the wrong place. I have recently downloaded the newest version of R (4.2.1.) and Rstudio (2022.07.1 Build 554). I was testing out an older previous document that knitted perfectly using the 'papaja' package and now a code chunk will not work (that worked previously) and provides this error message:

Error in compileCode(f, code, language = language, verbose = verbose) :
C:\rtools42\x86_64-w64-mingw32.static.posix\bin/ld.exe: file425c5d805023.o:file425c5d805023.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: file425c5d805023.o:file425c5d805023.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: file425c5d805023.o:file425c5d805023.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: file425c5d805023.o:file425c5d805023.cpp:(.text$_ZN3tbb10interface
Error in sink(type = "output") : invalid connection

I have the rtools42 and this worked with my previous version of R and Rstudio so I am not sure how to fix this. Help!

Software Engineer
  • 15,457
  • 7
  • 74
  • 102

1 Answers1

2

There are problems with the compatibility of R4.2, RTools42 and Rstan. For me, it worked to install the preview of rstan 2.26.x:

Remove an existing rstan:

remove.packages("rstan")
if (file.exists(".RData")) file.remove(".RData")

Install preview version of packages:

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")))

You can verify your installation with the example model:

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

References:

rstan/wiki/Configuring-C---Toolchain-for-Windows

rstan/wiki/RStan-Getting-Started

rstan-fit-error

Markus Bauer
  • 144
  • 1
  • 9