I came across this typical error when running brms. I have been using brms on this M1 Macbook for nearly a whole year, the problem just suddenly popped up. I have tried several potential solutions:
I reinstalled the latest version of R and RStudio.
I uninstalled and reinstalled xtools and gfortran. I followed " Configuring C Toolchain for Mac" and downloaded macrtools to check xtools and gfortran are both there. I also downloaded other binaries using macrtools::recipes_binary_install('r-base-dev')
. The problem still exists.
I still suspect it is the problem of CPP, because I couldn’t run Helloworld in R Compiler Tools for Rcpp on macOS | The Coatless Professor. But I have downloaded Rcpp and RcppArmadillo.
This is the code I tried to run:
m1 <- brm (R1~C1*P1+(1+C1*P1|ID)+(1+C1*P1|Subject),data=data1,
family = "bernoulli", chains=6, iter=4000, warmup=1000,
prior=c(set_prior ("cauchy (0, 2.5)")))
Below is the latest error I got.
make cmd is
make -f '/Library/Frameworks/R.framework/Resources/etc/Makeconf' -f '/Library/Frameworks/R.framework/Resources/share/make/shlib.mk' CXX='$(CXX14) $(CXX14STD)' CXXFLAGS='$(CXX14FLAGS)' CXXPICFLAGS='$(CXX14PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX14LDFLAGS)' SHLIB_LD='$(SHLIB_CXX14LD)' SHLIB='fileab35b468f7a.so' OBJECTS='fileab35b468f7a.o'
make would use
clang++ -arch arm64 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/Rcpp/include/" -I"/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/RcppEigen/include/" -I"/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/RcppEigen/include/unsupported" -I"/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/BH/include" -I"/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/StanHeaders/include/src/" -I"/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/StanHeaders/include/" -I"/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/RcppParallel/include/" -I"/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DBOOST_NO_AUTO_PTR -include '/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp' -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1 -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c fileab35b468f7a.cpp -o fileab35b468f7a.o
if test "zfileab35b468f7a.o" != "z"; then \
echo clang++ -arch arm64 -std=gnu++14 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L"/Library/Frameworks/R.framework/Resources/lib" -L/opt/R/arm64/lib -o fileab35b468f7a.so fileab35b468f7a.o '/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/rstan/lib//libStanServices.a' -L'/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/StanHeaders/lib/' -lStanHeaders -L'/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/RcppParallel/lib/' -ltbb -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation; \
clang++ -arch arm64 -std=gnu++14 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L"/Library/Frameworks/R.framework/Resources/lib" -L/opt/R/arm64/lib -o fileab35b468f7a.so fileab35b468f7a.o '/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/rstan/lib//libStanServices.a' -L'/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/StanHeaders/lib/' -lStanHeaders -L'/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/RcppParallel/lib/' -ltbb -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation; \
fi
Error in compileCode(f, code, language = language, verbose = verbose) :
/usr/local/include/math.h:165:5: note: expanded from macro 'isnan' ( sizeof(x) == sizeof(float) ? __inline_isnanf((float)(x)) \ ^fatal error: too many errors emitted, stopping now [-ferror-limit=]14 warnings and 20 errors generated.make: *** [fileab35b468f7a.o] Error 1
Error in sink(type = "output") : invalid connection
Please also provide the following information in addition to your question:
- Operating System: macOS Monterey 12.6
- brms Version: 2.19
- R: 4.3.2
Thank you!