Rstan build error (new 2.26.1): validate_dims is not a member of stan::io

This is a Stan headers compatibility issue, when the C++ code is generated by stanc3 and compiled with the old Stan headers. If you’re using the transitional version of StanHeaders 2.26.1, you need to define USE_STANC3 to access the new headers. This should be defined in the code generated by the latest version rstan::stanc (rstan 2.26.1), you can explicitly add -DUSE_STANC3 to CPPFLAGS.

utils::packageVersion("rstan")
utils::packageVersion("StanHeaders")