Issue Compiling All Stan Models Using RStan

Hello,

This is a crosspost from my github issue.

Whenever I attempt to compile any stan file in Rstan, I get the following error and my Rsession is aborted.

terminate called after throwing an instance of 'std::system_error'
  what():  Invalid argument
Abort trap: 6

To get this error, I put the following stan code in example.stan

// The input data is a vector 'y' of length 'N'.
data {
  int<lower=0> N;
  vector[N] y;
}

// The parameters accepted by the model. Our model
// accepts two parameters 'mu' and 'sigma'.
parameters {
  real mu;
  real<lower=0> sigma;
}

// The model to be estimated. We model the output
// 'y' to be normally distributed with mean 'mu'
// and standard deviation 'sigma'.
model {
  y ~ normal(mu, sigma);
}

Then, I call

rstan::stan_model(file = "example.stan")

Below is my sessionInfo:

R version 4.1.2 (2021-11-01)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.5

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rstan_2.21.3         ggplot2_3.3.5        StanHeaders_2.21.0-7

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.8         magrittr_2.0.2     tidyselect_1.1.1   munsell_0.5.0     
 [5] colorspace_2.0-3   R6_2.5.1           rlang_1.0.2        fansi_1.0.2       
 [9] dplyr_1.0.8        parallel_4.1.2     pkgbuild_1.3.0     grid_4.1.2        
[13] gtable_0.3.0       loo_2.5.0          utf8_1.2.2         cli_3.2.0         
[17] withr_2.5.0        matrixStats_0.61.0 ellipsis_0.3.2     RcppParallel_5.1.5
[21] tibble_3.1.6       lifecycle_1.0.1    crayon_1.5.0       processx_3.5.2    
[25] gridExtra_2.3      purrr_0.3.4        callr_3.7.0        codetools_0.2-18  
[29] ps_1.6.0           vctrs_0.3.8        inline_0.3.19      glue_1.6.2        
[33] compiler_4.1.2     pillar_1.7.0       prettyunits_1.1.1  generics_0.1.2    
[37] scales_1.1.1       stats4_4.1.2       pkgconfig_2.0.3   

I’m not sure why this is happening because I know that rstan was working on my machine before.

Any help is appreciated!

Eric.