Error when attempting to use ulam() function

Hi, I have some troubles running the code below (specifically the ulam() function).

d <- Wines2012
dat_list <- list(
  S = standardize(d$score),
  jid = as.integer(d$judge),
  wid = as.integer(d$wine)

m1 <- ulam(
    S ~ dnorm(mu, sigma),
    mu <- a[jid] + w[wid],
    a[jid] ~ dnorm(0, 0.5),
    w[wid] ~ dnorm(0, 0.5),
    sigma ~ dexp(1)
  ), data = dat_list, chains = 4, cores = 4

As soon as I try to run the ulam() function I get the following errors. I’ve tried to run it both in RStudios and VS Code. I have also tried reinstalling R and all the packages. Any help would be much appreciated.

Compiling Stan program…
INFO: Could not find files for the given pattern(s).

In file included from C:/rtools42/ucrt64/include/c++/12.2.0/stdlib.h:36,
from C:/rtools42/ucrt64/lib/gcc/x86_64-w64-mingw32/12.2.0/include/mm_malloc.h:27,
from C:/rtools42/ucrt64/lib/gcc/x86_64-w64-mingw32/12.2.0/include/xmmintrin.h:34,
from C:/rtools42/ucrt64/lib/gcc/x86_64-w64-mingw32/12.2.0/include/immintrin.h:31,
from …/tbb_2020.3/include/tbb/machine/gcc_itsx.h:57,
from …/tbb_2020.3/include/tbb/machine/gcc_ia32_common.h:107,
from …/tbb_2020.3/include/tbb/machine/gcc_generic.h:232,
from …/tbb_2020.3/include/tbb/tbb_machine.h:197,
from …/tbb_2020.3/src/tbbmalloc/Synchronize.h:20,
from …/tbb_2020.3/src/tbbmalloc/Customize.h:29,
from …/tbb_2020.3/src/tbbmalloc/TypeDefinitions.h:54,
from …/tbb_2020.3/src/tbbmalloc/tbbmalloc_internal.h:21,
from …/tbb_2020.3/src/tbbmalloc/backend.cpp:19:
C:/rtools42/ucrt64/include/c++/12.2.0/cstdlib:137:11: error: ‘at_quick_exit’ has not been declared in ‘::’
137 | using ::at_quick_exit;
| ^~~~~~~~~~~~~

C:/rtools42/ucrt64/include/c++/12.2.0/cstdlib:160:11: error: ‘quick_exit’ has not been declared in ‘::’
160 | using ::quick_exit;
| ^~~~~~~~~~
C:/rtools42/ucrt64/include/c++/12.2.0/stdlib.h:43:14: error: ‘at_quick_exit’ has not been declared in ‘std’
43 | using std::at_quick_exit;
| ^~~~~~~~~~~~~
C:/rtools42/ucrt64/include/c++/12.2.0/stdlib.h:46:14: error: ‘quick_exit’ has not been declared in ‘std’
46 | using std::quick_exit;
| ^~~~~~~~~~

cc1plus.exe: note: unrecognized command-line option ‘-Wno-unknown-warning-option’ may have been intended to silence earlier diagnostics

mingw32-make[1]: *** [C:/Users/Michael Dang/Documents/.cmdstan/cmdstan-2.30.1/stan/lib/stan_math/lib/tbb_2020.3/build/Makefile.tbbmalloc:65: backend.o] Error 1

mingw32-make: *** [stan/lib/stan_math/make/libraries:173: stan/lib/stan_math/lib/tbb/tbbmalloc.def] Error 2

Error: An error occured during compilation! See the message above for more information.