Rstan Issues on Mac: empty_nested() must be true before calling recover_memory()

Hi folks,

Long time listener, first time caller. I know this issue has come up before but I’ve had a lot of trouble seeking the right answer so I’d appreciate any input. I recently installed rstan, brms, and rstanarm on a new machine and everytime I set algorithm to “sampling”, I run into an issue where the output indicates: Chain 1: empty_nested() must be true before calling recover_memory()

For example, if i run:

data(iris)
rstanarm::stan_glm(Sepal.Length~Sepal.Width, 
                     data=iris, algorithm = 'sampling')

then I receive the following output:

SAMPLING FOR MODEL 'continuous' NOW (CHAIN 1).
Chain 1: empty_nested() must be true before calling recover_memory()
[1] "Error in sampler$call_sampler(args_list[[i]]) : "             
[2] "  empty_nested() must be true before calling recover_memory()"
error occurred during calling the sampler; sampling not done
Error in check_stanfit(stanfit) : 
  Invalid stanfit object produced please report bug

My hunch is this is related to the previously reported issues with R, Stan, and Mac compilers but I’m not entirely sure.

Current version:

platform       x86_64-apple-darwin15.6.0   
arch           x86_64                      
os             darwin15.6.0                
system         x86_64, darwin15.6.0        
status                                     
major          3                           
minor          6.3                         
year           2020                        
month          02                          
day            29                          
svn rev        77875                       
language       R                           
version.string R version 3.6.3 (2020-02-29)
nickname       Holding the Windsock  

running under: Running under: OS X Snow Leopard 11.6.1.

Additionally, my gcc version is:

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Any feedback would be greatly appreciated. I have rstan successfully set up on another machine but need to be able to run it on this machine as well. Thank you.

1 Like

Definitely looks like a tool chain issue. I would just try reinstalling things, following the install guide for Mac, possibly updating to later versions (R 4.0 and latest rstan via Repository for distributing (some) stan-dev R packages | r-packages)

Hope you can get it running soon