Can't upgrade to latest StanHeaders package in R

I have a model that runs under R 4.2.1. Packages are managed with renv. See session info below for working packages.

I’ve updated all packages but updating StanHeaders causes the model to fail when running. If I update StanHeaders to 2.26.27 the models compile and run but eat up all free RAM until the session crashes. This happens when run in RStudio or run from the terminal.

Session info (working):

> sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.6 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas/
LAPACK: /usr/lib/x86_64-linux-gnu/

 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 

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

other attached packages:
 [1] rstan_2.21.8         StanHeaders_2.21.0-7 qs_0.25.5            lubridate_1.9.2      forcats_1.0.0        stringr_1.5.0       
 [7] dplyr_1.1.2          purrr_1.0.1          readr_2.1.4          tidyr_1.3.0          tibble_3.2.1         ggplot2_3.4.2       
[13] tidyverse_2.0.0     

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.11          prettyunits_1.1.1    ps_1.7.5             digest_0.6.33        utf8_1.2.3           R6_2.5.1            
 [7] cellranger_1.1.0     backports_1.4.1      stats4_4.2.1         pillar_1.9.0         rlang_1.1.1          rematch_1.0.1       
[13] readxl_1.4.3         rstudioapi_0.15.0    callr_3.7.3          R.utils_2.12.2       R.oo_1.25.0          checkmate_2.2.0     
[19] styler_1.10.1        labeling_0.4.2       loo_2.6.0            bit_4.0.5            munsell_0.5.0        xfun_0.39           
[25] compiler_4.2.1       pkgconfig_2.0.3      pkgbuild_1.4.2       tidyselect_1.2.0     tensorA_0.36.2       gridExtra_2.3       
[31] codetools_0.2-19     matrixStats_1.0.0    fansi_1.0.4          crayon_1.5.2         tzdb_0.4.0           withr_2.5.0         
[37] R.methodsS3_1.8.2    grid_4.2.1           distributional_0.3.2 gtable_0.3.3         lifecycle_1.0.3      magrittr_2.0.3      
[43] posterior_1.4.1      scales_1.2.1         RcppParallel_5.1.7   cli_3.6.1            stringi_1.7.12       vroom_1.6.3         
[49] farver_2.1.1         renv_1.0.0           generics_0.1.3       vctrs_0.6.3          stringfish_0.15.8    RApiSerialize_0.1.2 
[55] tools_4.2.1          bit64_4.0.5          R.cache_0.16.0       glue_1.6.2           hms_1.1.3            processx_3.8.2      
[61] abind_1.4-5          parallel_4.2.1       yaml_2.3.7           timechange_0.2.0     inline_0.3.19        colorspace_2.1-0    
[67] knitr_1.43  

Resolved by adding package repository per instructions here.

It’s a bit odd as CRAN has StanHeaders v2.26.27 and rstan v2.21.8. These don’t appear to work together.

Seems to now work with StanHeaders and rstan both on 2.26.22.


CRAN left us here when they went on vacation! This has been a huge struggle because there’s no mechanism within CRAN to enforce dependencies among packages and they’ve accepted 2.26 and then booted it off.

If you can, I’d suggest completely avoiding CRAN when it comes to dealing with RStan, etc.

1 Like

The newer StanHeaders should be backwards compatible with the older RStan (all the tests on CRAN passed with those versions together), but we’re seeing reports that in some cases it’s not working. Installing them both from source instead of binary sometimes fixes that. In your case you don’t need that since you resolved it by installing from other repository.

I think @andrjohns @hsbadr and @bgoodri are working on getting the newer RStan on CRAN too now that StanHeaders was accepted.

But yeah like @Bob_Carpenter said we’re on hold while CRAN is on vacation.

In this case it didn’t work together. Not sure if it was installed from source as I was returning to a project I had not used before.