Error in sink(type = "output"): invalid connection

Problem

I am trying to run the code/model from this project https://github.com/ImperialCollegeLondon/covid19model. They provide a conda environment.yml file which I used to create an environment containing R, Stan and dependencies, but the environment isn’t working for me.

I have looked at other posts referring to similar error messages, and found information that has helped me investigate, but I have not yet found the solution to my problem.

I used information in one of the other posts to start trying to get a basic Stan model to run, but even this isn’t working:

m <- stan_model(model_code = 'parameters {real y;} model {y ~ normal(0,1);}', 
                obfuscate_model_name = FALSE)

The output I get is:

Warning message in system(cmd, intern = !verbose):
“running command '/opt/conda/lib/R/bin/R CMD SHLIB file662e54cea2.cpp 2> file662e54cea2.cpp.err.txt' had status 1”
Error in compileCode(f, code, language = language, verbose = verbose): Compilation ERROR, function(s)/method(s) not created! file662e54cea2.cpp:6:36: warning: ISO C++11 requires whitespace after the macro name
 #define STAN__SERVICES__COMMAND_HPP#include <boost/integer/integer_log2.hpp>
                                    ^
In file included from /opt/conda/lib/R/library/RcppEigen/include/Eigen/Core:383:0,
                 from /opt/conda/lib/R/library/RcppEigen/include/Eigen/Dense:1,
                 from /opt/conda/lib/R/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4,
                 from <command-line>:0:
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:60:39: warning: ignoring attributes on template argument '__m128 {aka __vector(4) float}' [-Wignored-attributes]
 template<> struct is_arithmetic<__m128>  { enum { value = true }; };
                                       ^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:61:40: warning: ignoring attributes on template argument '__m128i {aka __vector(2) long long int}' [-Wignored-attributes]
 template<> struct is_arithmetic<__m128i> { enum { value = true }; };
                                        ^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:62:40: warning: ignoring attributes on template argument '__m128d {aka __vector(2) double}' [-Wignored-attributes]
 template<> struct is_arithmetic<__m128d> { enum { value = true }; };
                                        ^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:161:43: warning: ignoring attributes on template argument 'Eigen::internal::Packet4f {aka __vector(4) float}' [-Wignored-attributes]
 template<> struct unpacket_traits<Packet4f> { typedef float  type; enum {size=4, alignment=Aligned16}; typedef Packet4f half; };
                                           ^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:162:43: warning: ignoring attributes on template argument 'Eigen::internal::Packet2d {aka __vector(2) double}' [-Wignored-attributes]
 template<> struct unpacket_traits<Packet2d> { typedef double type; enum {size=2, alignment=Aligned16}; typedef Packet2d half; };
                                           ^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:163:43: warning: ignoring attributes on template argument 'Eigen::internal::Packet4i {aka __vector(2) long long int}' [-Wignored-attributes]
 template<> struct unpacket_traits<Packet4i> { typedef int    type; enum {size=4, alignment=Aligned16}; typedef Packet4i half; };
                                           ^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:687:35: warning: ignoring attributes on template argument 'Eigen::internal::Packet4f {aka __vector(4) float}' [-Wignored-attributes]
 struct palign_impl<Offset,Packet4f>
                                   ^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:697:35: warning: ignoring attributes on template argument 'Eigen::internal::Packet4i {aka __vector(2) long long int}' [-Wignored-attributes]
 struct palign_impl<Offset,Packet4i>
                                   ^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:707:35: warning: ignoring attributes on template argument 'Eigen::internal::Packet2d {aka __vector(2) double}' [-Wignored-attributes]
 struct palign_impl<Offset,Packet2d>
                                   ^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:778:34: warning: ignoring attributes on template argument 'Eigen::internal::Packet4f {aka __vector(4) float}' [-Wignored-attributes]
 ptranspose(PacketBlock<Packet4f,4>& kernel) {
                                  ^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:783:34: warning: ignoring attributes on template argument 'Eigen::internal::Packet2d {aka __vector(2) double}' [-Wignored-attributes]
 ptranspose(PacketBlock<Packet2d,2>& kernel) {
                                  ^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/PacketMath.h:790:34: warning: ignoring attributes on template argument 'Eigen::internal::Packet4i {aka __vector(2) long long int}' [-Wignored-attributes]
 ptranspose(PacketBlock<Packet4i,4>& kernel) {
                                  ^
In file included from /opt/conda/lib/R/library/RcppEigen/include/Eigen/Core:374:0,
                 from /opt/conda/lib/R/library/RcppEigen/include/Eigen/Dense:1,
                 from /opt/conda/lib/R/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4,
                 from <command-line>:0:
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/Default/ConjHelper.h:15:70: warning: ignoring attributes on template argument 'Eigen::internal::Packet4f {aka __vector(4) float}' [-Wignored-attributes]
   template<> struct conj_helper<PACKET_REAL, PACKET_CPLX, false,false> {                                          \
                                                                      ^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/Complex.h:232:1: note: in expansion of macro 'EIGEN_MAKE_CONJ_HELPER_CPLX_REAL'
 EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(Packet2cf,Packet4f)
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/Default/ConjHelper.h:22:70: warning: ignoring attributes on template argument 'Eigen::internal::Packet4f {aka __vector(4) float}' [-Wignored-attributes]
   template<> struct conj_helper<PACKET_CPLX, PACKET_REAL, false,false> {                                          \
                                                                      ^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/Complex.h:232:1: note: in expansion of macro 'EIGEN_MAKE_CONJ_HELPER_CPLX_REAL'
 EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(Packet2cf,Packet4f)
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/Default/ConjHelper.h:15:70: warning: ignoring attributes on template argument 'Eigen::internal::Packet2d {aka __vector(2) double}' [-Wignored-attributes]
   template<> struct conj_helper<PACKET_REAL, PACKET_CPLX, false,false> {                                          \
                                                                      ^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/Complex.h:417:1: note: in expansion of macro 'EIGEN_MAKE_CONJ_HELPER_CPLX_REAL'
 EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(Packet1cd,Packet2d)
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/Default/ConjHelper.h:22:70: warning: ignoring attributes on template argument 'Eigen::internal::Packet2d {aka __vector(2) double}' [-Wignored-attributes]
   template<> struct conj_helper<PACKET_CPLX, PACKET_REAL, false,false> {                                          \
                                                                      ^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/SSE/Complex.h:417:1: note: in expansion of macro 'EIGEN_MAKE_CONJ_HELPER_CPLX_REAL'
 EIGEN_MAKE_CONJ_HELPER_CPLX_REAL(Packet1cd,Packet2d)
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /opt/conda/lib/R/library/RcppEigen/include/Eigen/Core:386:0,
                 from /opt/conda/lib/R/library/RcppEigen/include/Eigen/Dense:1,
                 from /opt/conda/lib/R/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:4,
                 from <command-line>:0:
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/AVX/PacketMath.h:35:39: warning: ignoring attributes on template argument '__m256 {aka __vector(8) float}' [-Wignored-attributes]
 template<> struct is_arithmetic<__m256>  { enum { value = true }; };
                                       ^
/opt/conda/lib/R/library/RcppEigen/include/Eigen/src/Core/arch/AVX/PacketMath.h:36:40: warning: ignoring attributes on template argument '__m256i {aka __vector(4) long long int}' [-Wignored-attributes]
 template<> struct is_arithmetic<__m256i> { enum { value = true }; };
              
Traceback:

1. stan_model(model_code = "parameters {real y;} model {y ~ normal(0,1);}", 
 .     obfuscate_model_name = FALSE)
2. cxxfunctionplus(signature(), body = paste(" return Rcpp::wrap(\"", 
 .     model_name, "\");", sep = ""), includes = inc, plugin = "rstan", 
 .     save_dso = save_dso | auto_write, module_name = paste("stan_fit4", 
 .         model_cppname, "_mod", sep = ""), verbose = verbose)
3. pkgbuild::with_build_tools(cxxfunction(sig = sig, body = body, 
 .     plugin = plugin, includes = includes, settings = settings, 
 .     ..., verbose = verbose), required = rstan_options("required") && 
 .     !identical(Sys.getenv("WINDOWS"), "TRUE") && !identical(Sys.getenv("R_PACKAGE_SOURCE"), 
 .     ""))
4. cxxfunction(sig = sig, body = body, plugin = plugin, includes = includes, 
 .     settings = settings, ..., verbose = verbose)
5. compileCode(f, code, language = language, verbose = verbose)
6. stop(paste("Compilation ERROR, function(s)/method(s) not created!", 
 .     paste(errmsg, collapse = "\n")))
Error in sink(type = "output"): invalid connection
Traceback:

1. stan_model(model_code = "parameters {real y;} model {y ~ normal(0,1);}", 
 .     obfuscate_model_name = FALSE)
2. cxxfunctionplus(signature(), body = paste(" return Rcpp::wrap(\"", 
 .     model_name, "\");", sep = ""), includes = inc, plugin = "rstan", 
 .     save_dso = save_dso | auto_write, module_name = paste("stan_fit4", 
 .         model_cppname, "_mod", sep = ""), verbose = verbose)
3. sink(type = "output")

As mentioned in the beginning of the long error message, the C++ code that is emitted by Stan doesn’t look entirely right to my eyes. In particular, it includes this line:
#define STAN__SERVICES__COMMAND_HPP#include <boost/integer/integer_log2.hpp>

Libraries

packageVersion("BH"): ‘1.72.0.3’

pkgbuild::has_build_tools(debug = TRUE) works and returns TRUE along with this console logging:

Running /opt/conda/lib/R/bin/R CMD SHLIB foo.c
x86_64-conda_cos6-linux-gnu-cc -I"/opt/conda/lib/R/include" -DNDEBUG   -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /opt/conda/include -I/opt/conda/include -Wl,-rpath-link,/opt/conda/lib  -fpic  -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /opt/conda/include -fdebug-prefix-map=/home/conda/feedstock_root/build_artifacts/r-base_1585837569147/work=/usr/local/src/conda/r-base-3.6.3 -fdebug-prefix-map=/opt/conda=/usr/local/src/conda-prefix  -c foo.c -o foo.o
x86_64-conda_cos6-linux-gnu-cc -shared -L/opt/conda/lib/R/lib -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,-rpath,/opt/conda/lib -Wl,-rpath-link,/opt/conda/lib -L/opt/conda/lib -Wl,-rpath-link,/opt/conda/lib -o foo.so foo.o -L/opt/conda/lib/R/lib -lR

Operating System: Ubuntu 18.04.4 LTS
Interface Version: packageVersion("rstan"): ‘2.19.3’
Compiler/Toolkit: gcc --version: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0

Any tips or pointers would be greatly appreciated. Thanks!

It looks like you need to do

but Conda often messes the configuration up.

2 Likes

Thanks a lot for the quick response! It is much appreciated.

Running the C++ toolchain configuration command referenced in that link doesn’t change the output.

I’ve been trying to get the Stan-generated C++ to compile by hand (BTW is there any way to print the makefile or gcc command used by Stan to compile the file – I just cobbled together the following from what I found in logging messages).

Executing this
g++ -v -Wno-deprecated-declarations -Wno-ignored-attributes -std=c++14 -O3 -march=native -mtune=native -fPIC -L'/opt/conda/lib/R/library/StanHeaders/lib/' -lStanHeaders -I"/opt/conda/lib/R/include/" -I"/opt/conda/lib/R/library/Rcpp/include/" -I"/opt/conda/lib/R/library/RcppEigen/include/" -I"/opt/conda/lib/R/library/RcppEigen/include/unsupported" -I"/opt/conda/lib/R/library/BH/include" -I"/opt/conda/lib/R/library/StanHeaders/include/src/" -I"/opt/conda/lib/R/library/StanHeaders/include/" -I"/opt/conda/lib/R/library/rstan/include" -DEIGEN_NO_DEBUG -D_REENTRANT -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -include stan/math/prim/mat/fun/Eigen.hpp toy.cpp -o toy.o

(toy.cpp is just one of the Stan-generated cpp files renamed) yields this output:

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.5.0-3ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) 
COLLECT_GCC_OPTIONS='-v' '-Wno-deprecated-declarations' '-Wno-ignored-attributes' '-std=c++14' '-O3' '-march=native' '-mtune=native' '-fPIC' '-L/opt/conda/lib/R/library/StanHeaders/lib/' '-I' '/opt/conda/lib/R/include/' '-I' '/opt/conda/lib/R/library/Rcpp/include/' '-I' '/opt/conda/lib/R/library/RcppEigen/include/' '-I' '/opt/conda/lib/R/library/RcppEigen/include/unsupported' '-I' '/opt/conda/lib/R/library/BH/include' '-I' '/opt/conda/lib/R/library/StanHeaders/include/src/' '-I' '/opt/conda/lib/R/library/StanHeaders/include/' '-I' '/opt/conda/lib/R/library/rstan/include' '-D' 'EIGEN_NO_DEBUG' '-D' '_REENTRANT' '-D' 'BOOST_DISABLE_ASSERTS' '-D' 'BOOST_PENDING_INTEGER_LOG2_HPP' '-include' 'stan/math/prim/mat/fun/Eigen.hpp' '-o' 'toy.o' '-shared-libgcc'
 /usr/lib/gcc/x86_64-linux-gnu/7/cc1plus -quiet -v -I /opt/conda/lib/R/include/ -I /opt/conda/lib/R/library/Rcpp/include/ -I /opt/conda/lib/R/library/RcppEigen/include/ -I /opt/conda/lib/R/library/RcppEigen/include/unsupported -I /opt/conda/lib/R/library/BH/include -I /opt/conda/lib/R/library/StanHeaders/include/src/ -I /opt/conda/lib/R/library/StanHeaders/include/ -I /opt/conda/lib/R/library/rstan/include -imultiarch x86_64-linux-gnu -D_GNU_SOURCE -D EIGEN_NO_DEBUG -D _REENTRANT -D BOOST_DISABLE_ASSERTS -D BOOST_PENDING_INTEGER_LOG2_HPP -include stan/math/prim/mat/fun/Eigen.hpp toy.cpp -march=broadwell -mmmx -mno-3dnow -msse -msse2 -msse3 -mssse3 -mno-sse4a -mcx16 -msahf -mmovbe -maes -mno-sha -mpclmul -mpopcnt -mabm -mno-lwp -mfma -mno-fma4 -mno-xop -mbmi -mno-sgx -mbmi2 -mno-tbm -mavx -mavx2 -msse4.2 -msse4.1 -mlzcnt -mrtm -mhle -mrdrnd -mf16c -mfsgsbase -mrdseed -mprfchw -madx -mfxsr -mxsave -mxsaveopt -mavx512f -mno-avx512er -mavx512cd -mno-avx512pf -mno-prefetchwt1 -mno-clflushopt -mno-xsavec -mno-xsaves -mno-avx512dq -mno-avx512bw -mno-avx512vl -mno-avx512ifma -mno-avx512vbmi -mno-avx5124fmaps -mno-avx5124vnniw -mno-clwb -mno-mwaitx -mno-clzero -mno-pku -mno-rdpid --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=4096 -mtune=broadwell -quiet -dumpbase toy.cpp -auxbase toy -O3 -Wno-deprecated-declarations -Wno-ignored-attributes -std=c++14 -version -fPIC -fstack-protector-strong -Wformat -Wformat-security -o /tmp/ccVinue1.s
GNU C++14 (Ubuntu 7.5.0-3ubuntu1~18.04) version 7.5.0 (x86_64-linux-gnu)
        compiled by GNU C version 7.5.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/7"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/7/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/conda/lib/R/include/
 /opt/conda/lib/R/library/Rcpp/include/
 /opt/conda/lib/R/library/RcppEigen/include/
 /opt/conda/lib/R/library/RcppEigen/include/unsupported
 /opt/conda/lib/R/library/BH/include
 /opt/conda/lib/R/library/StanHeaders/include/src/
 /opt/conda/lib/R/library/StanHeaders/include/
 /opt/conda/lib/R/library/rstan/include
 /usr/include/c++/7
 /usr/include/x86_64-linux-gnu/c++/7
 /usr/include/c++/7/backward
 /usr/lib/gcc/x86_64-linux-gnu/7/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
GNU C++14 (Ubuntu 7.5.0-3ubuntu1~18.04) version 7.5.0 (x86_64-linux-gnu)
        compiled by GNU C version 7.5.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 3eb3dc290cd5714c3e1c3ae751116f07
toy.cpp:34:40: error: expected template-name before ‘<’ token
   : public stan::model::model_base_crtp<model_a4ac6057f98b19ab6241bf06f3c8ead7> {
                                        ^
toy.cpp:34:40: error: expected ‘{’ before ‘<’ token
toy.cpp:34:40: error: expected unqualified-id before ‘<’ token
In file included from /opt/conda/lib/R/library/rstan/include/rstan/rstaninc.hpp:3:0,
                 from toy.cpp:8:
/opt/conda/lib/R/library/rstan/include/rstan/stan_fit.hpp: In instantiation of ‘class rstan::stan_fit<model_a4ac6057f98b19ab6241bf06f3c8ead7_namespace::model_a4ac6057f98b19ab6241bf06f3c8ead7, boost::random::additive_combine_engine<boost::random::linear_congruential_engine<unsigned int, 40014, 0, 2147483563>, boost::random::linear_congruential_engine<unsigned int, 40692, 0, 2147483399> > >’:
toy.cpp:321:146:   required from here
/opt/conda/lib/R/library/rstan/include/rstan/stan_fit.hpp:916:9: error: ‘rstan::stan_fit<Model, RNG_t>::model_’ has incomplete type
   Model model_;
         ^~~~~~
toy.cpp:33:7: note: forward declaration of ‘class model_a4ac6057f98b19ab6241bf06f3c8ead7_namespace::model_a4ac6057f98b19ab6241bf06f3c8ead7’
 class model_a4ac6057f98b19ab6241bf06f3c8ead7

It looks like model_base_crtp should be defined in <stan/model/model_base_crtp.hpp>, but I cannot seem to find this file.

ls /opt/conda/lib/R/library/StanHeaders/include/src/stan/model/
finite_diff_grad.hpp             hessian_times_vector.hpp         model_header.hpp
grad_hess_log_prob.hpp           indexing/                        prob_grad.hpp
gradient_dot_vector.hpp          indexing.hpp                     standalone_functions_header.hpp
gradient.hpp                     log_prob_grad.hpp                test_gradients.hpp
grad_tr_mat_times_hessian.hpp    log_prob_propto.hpp              
hessian.hpp                      model_functional.hpp 

And
find /opt/conda/lib/R/ -name "model_base_crtp.hpp" returns nothing.

Is this maybe the source of the problem or am I barking up the wrong tree?

I think you have rstan mismatched with StanHeaders. I would reinstall rstan from source via CRAN in a clean R session.

1 Like

You were right. rstan was on version 2.19.3, StanHeaders was on version 2.21.0. I tried installing using conda with pinned down minor version numbers, but I still had the same problem.

I couldn’t get it installed over conda, but installing rstan using CRAN worked. Thanks!