RStan sometimes recompiles to avoid crashing R session

The make-like behavior of RStan model compilation seems to only work intermittently for me. Sometimes, when I recompile, I see this:

recompiling to avoid crashing R session

When does that arise? I haven’t been able to create a reproducible example from a fresh start of R.

P.S.

> sessionInfo()
R version 3.5.0 (2018-04-23)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/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.17.3       StanHeaders_2.17.2 ggplot2_2.2.1     

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.17     grid_3.5.0       plyr_1.8.4       gtable_0.2.0    
 [5] stats4_3.5.0     scales_0.5.0     pillar_1.2.3     rlang_0.2.1     
 [9] lazyeval_0.2.1   tools_3.5.0      munsell_0.4.3    compiler_3.5.0  
[13] inline_0.3.15    colorspace_1.3-2 gridExtra_2.3    tibble_1.4.2  

AFAIK, this happens when the original model object is garbage collected. The best way to avoid is to always build the model with a call to stan_model and keep the resulting variable around. See those issues for (some) more details:


That’s what I normally do just to make the code clearer (to me), but here I was running someone else’s script.