If I run
example(stan_model, package = "rstan", run.dontrun = TRUE)
RStudio answers:
Building R package from source requires installation of additional build tools.
Do you want to install the additional tools now?
The question comes up twice.
Whether I click Yes or No, I end up with an error message as below:
Error in compileCode(f, code, language = language, verbose = verbose) :
In file included from :1:In file included from /Library/Frameworks/R.framework/Versions/4.2/Resources/library/StanHeaders/include/stan/math/prim/fun/Eigen.hpp:22:In file included from /Library/Frameworks/R.framework/Versions/4.2/Resources/library/RcppEigen/include/Eigen/Dense:1:In file included from /Library/Frameworks/R.framework/Versions/4.2/Resources/library/RcppEigen/include/Eigen/Core:82:In file included from /usr/local/clang6/include/c++/v1/new:91:In file included from /usr/local/clang6/include/c++/v1/exception:82:In file included from /usr/local/clang6/include/c++/v1/cstdlib:86:/usr/local/clang6/include/c++/v1/stdlib.h:94:15: fatal error: ‘stdlib.h’ file not found#include_next <stdlib.h> ^~~~~~~~~~1 error generated.make: *** [file85623a4758e7.o] Error 1
Restarting R and using VS code instead, again runnning
example(stan_model, package = "rstan", run.dontrun = TRUE)
gives the same error:
Compilation ERROR, function(s)/method(s) not created!
Error in compileCode(f, code, language = language, verbose = verbose) :
In file included from :1:In file included from /Library/Frameworks/R.framework/Versions/4.2/Resources/library/StanHeaders/include/stan/math/prim/fun/Eigen.hpp:22:In file included from /Library/Frameworks/R.framework/Versions/4.2/Resources/library/RcppEigen/include/Eigen/Dense:1:In file included from /Library/Frameworks/R.framework/Versions/4.2/Resources/library/RcppEigen/include/Eigen/Core:82:In file included from /usr/local/clang6/include/c++/v1/new:91:In file included from /usr/local/clang6/include/c++/v1/exception:82:In file included from /usr/local/clang6/include/c++/v1/cstdlib:86:/usr/local/clang6/include/c++/v1/stdlib.h:94:15: fatal error: ‘stdlib.h’ file not found#include_next <stdlib.h> ^~~~~~~~~~1 error generated.make: *** [file8b323693afb5.o] Error 1
I see that I have more than one “stdlib.h” on disc, all from long back.
I have tried to follow several online suggestions, with no luck.
My attempt to use brms
(which I want to use) originally triggered this error. But strangely, I am able to run a regression model with blavaan
(which I believe calls RStan
), but blavaan
is currently very slow. So if I’m to stick with R, I’d like to use brms
.
How do I solve this problem when running RStan
and brms
?
Christopher