Failing to install brms on Big Sur

Hello,

I am failing to properly install brms on my macBook Pro and do not know how to solve this problem on my own. I updated to Big Sur (11.2.3) and to make sure that brms would work, I set it up on the ‘naked’ system and it worked okay (threw some warning message, but could create models).

However, when I copied all my data, software and settings from my old macBook, brms does not work anymore. I uninstalled R, Rstudio, XCode and reinstalled with the newest versions. Still, I get stuck when I want to run a model. The output is the following in combination with an R popup window:

“Compiling Stan program…
sh: clang++ -mmacosx-version-min=10.13: command not found
The NEXT version of Stan will not be able to pre-process your Stan program.
Please open an issue at
Issues · stan-dev/stanc3 · GitHub
if you can share or at least describe your Stan program. This will help ensure that Stan
continues to work on your Stan programs in the future. Thank you!
This message can be avoided by wrapping your function call inside suppressMessages().”

The R popup window informs me that I need to install build tools (which however, I did). If I answer yes, it does nothing (In an earlier attempt it would take me to a website informing me how to install build tools). If I answer no, I get the following R output:

"
make cmd is
make -f ‘/Library/Frameworks/R.framework/Resources/etc/Makeconf’ -f ‘/Library/Frameworks/R.framework/Resources/share/make/shlib.mk’ -f ‘/Users/jzimmermann/.R/Makevars’ CXX=’(CXX14) (CXX14STD)’ CXXFLAGS=’(CXX14FLAGS)' CXXPICFLAGS='(CXX14PICFLAGS)’ SHLIB_LDFLAGS=’(SHLIB_CXX14LDFLAGS)' SHLIB_LD='(SHLIB_CXX14LD)’ SHLIB=‘file22e3726b2d81.so’ OBJECTS=‘file22e3726b2d81.o’

make would use
if test “zfile22e3726b2d81.o” != “z”; then
echo clang++ -mmacosx-version-min=10.13 -std=gnu++14 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -Wl,-rpath,/Library/Frameworks/R.framework/Resources/lib /Library/Frameworks/R.framework/Resources/lib/libc++abi.1.dylib -L"/Library/Frameworks/R.framework/Resources/lib" -L/usr/local/lib -o file22e3726b2d81.so file22e3726b2d81.o /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/lib//libStanServices.a -L’/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/lib/’ -lStanHeaders -L’/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppParallel/lib/’ -ltbb -ltbbmalloc -ltbbmalloc_proxy -F/Library/Frameworks/R.framework/… -framework R -Wl,-framework -Wl,CoreFoundation;
clang++ -mmacosx-version-min=10.13 -std=gnu++14 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -Wl,-rpath,/Library/Frameworks/R.framework/Resources/lib /Library/Frameworks/R.framework/Resources/lib/libc++abi.1.dylib -L"/Library/Frameworks/R.framework/Resources/lib" -L/usr/local/lib -o file22e3726b2d81.so file22e3726b2d81.o /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/lib//libStanServices.a -L’/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/lib/’ -lStanHeaders -L’/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppParallel/lib/’ -ltbb -ltbbmalloc -ltbbmalloc_proxy -F/Library/Frameworks/R.framework/… -framework R -Wl,-framework -Wl,CoreFoundation;
fi
Error in compileCode(f, code, language = language, verbose = verbose) :
file22e3726b2d81.cpp:192:24: warning: unused typedef ‘local_scalar_t__’ [-Wunused-local-typedef] typedef double local_scalar_t__; ^29 warnings generated.clang-7: error: no such file or directory: '/Library/Frameworks/R.framework/Resources/lib/libc++abi.1.dylib’make: *** [file22e3726b2d81.so] Error 1
In addition: Warning messages:
1: Rows containing NAs were excluded from the model.
2: In system2(CXX, args = ARGS) : error in running command
3: In file.remove(c(unprocessed, processed)) :
cannot remove file ‘/var/folders/j9/ttvwqt113mg7bvr4lv409jbh0000gn/T//RtmpC4ngvg/file22e37ea6ce62.stan’, reason ‘No such file or directory’
Error in sink(type = “output”) : invalid connection

"

Hi!

What‘s the output of system("cat ~/.R/Makevars")?

Regards,
Pascal

I had some problem as well and used

dotR ← file.path(Sys.getenv(“HOME”), “.R”)
if (!file.exists(dotR)) dir.create(dotR)
M ← file.path(dotR, “Makevars”)
if (!file.exists(M)) file.create(M)
cat("\nCXX14FLAGS += -O3 -mtune=native -arch x86_64 -ftemplate-depth-256",
file = M, sep = “\n”, append = FALSE)

if (!requireNamespace(“remotes”)) {
install.packages(“remotes”)

remotes::install_github(“paul-buerkner/brms”)

In my case this worked. Maybe this won’t help yo but just in case…

Hi and thanks for getting back to me!
The output in R is this:

# clang: start
CFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CCFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CXXFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
CPPFLAGS=-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include

SHLIB_CXXLDFLAGS+=-Wl,-rpath,${R_HOME}/lib ${R_HOME}/lib/libc++abi.1.dylib
SHLIB_CXX14LDFLAGS+=-Wl,-rpath,${R_HOME}/lib ${R_HOME}/lib/libc++abi.1.dylib
# clang: end

Hi!

Try

system("mv ~/.R/Makevars ~/.R/Makevars.backup")

and afterwards all of the following:

Reinstall brms afterwards.

Regards,
Pascal

Hi again,

when I run

system("mv ~/.R/Makevars ~/.R/Makevars.backup")

in R, I get this and do not know how to get permission in R. Or am I supposed to run this in the terminal?

mv: rename /Users/MYUSERNAME/.R/Makevars to /Users/MYUSERNAME/.R/Makevars.backup: Permission denied

Renaming files does not seem to work with the system command…

Run

in the terminal.

Regards

Thank you, I did this and it now got rid of the first ‘missing-command’-output I got in the beginning. However, I still get the R-popup window telling me that command line tools are needed, and the following output (also, the model is not created):

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=‘file5341389afe71.so’ OBJECTS=‘file5341389afe71.o’

make would use
clang++ -mmacosx-version-min=10.13 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/unsupported" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/BH/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppParallel/include/" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DUSE_STANC3 -DSTRICT_R_HEADERS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -DBOOST_NO_AUTO_PTR -include ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/fun/Eigen.hpp’ -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1 -I/usr/local/include -fPIC -Wall -g -O2 -c file5341389afe71.cpp -o file5341389afe71.o
if test “zfile5341389afe71.o” != “z”; then
echo clang++ -mmacosx-version-min=10.13 -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/usr/local/lib -o file5341389afe71.so file5341389afe71.o ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/lib//libStanServices.a’ -L’/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/lib/’ -lStanHeaders -L’/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppParallel/lib/’ -ltbb -F/Library/Frameworks/R.framework/… -framework R -Wl,-framework -Wl,CoreFoundation;
clang++ -mmacosx-version-min=10.13 -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/usr/local/lib -o file5341389afe71.so file5341389afe71.o ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/lib//libStanServices.a’ -L’/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/lib/’ -lStanHeaders -L’/Library/Frameworks/R.framework/Versions/4.0/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) :
In file included from :1:In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/fun/Eigen.hpp:22:In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Dense:1:In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Core:82:In file included from /usr/local/clang7/include/c++/v1/new:91:In file included from /usr/local/clang7/include/c++/v1/exception:82:In file included from /usr/local/clang7/include/c++/v1/cstdlib:86:/usr/local/clang7/include/c++/v1/stdlib.h:94:15: fatal error: ‘stdlib.h’ file not found#include_next <stdlib.h> ^~~~~~~~~~1 error generated.make: *** [file5341389afe71.o] Error 1
In addition: Warning message:
Rows containing NAs were excluded from the model.
Error in sink(type = “output”) : invalid connection

Have you executed these commands?

Then, try completely removing and reinstalling StanHeaders, rstan and brms.

remove.packages(c("rstan", "StanHeaders", "brms"))
install.packages(c("rstan", "StanHeaders", "brms"))

Hi, yes I executed the commands in R.

dotR ← file.path(Sys.getenv("HOME"), ".R")
if (!file.exists(dotR)) dir.create(dotR)
M ← file.path(dotR, "Makevars")
if (!file.exists(M)) file.create(M)
cat("\nCXX14FLAGS += -O3 -mtune=native -arch x86_64 -ftemplate-depth-256",
file = M, sep = "\n", append = FALSE)

Now, I additionally executed these:

remove.packages(c("rstan", "StanHeaders", "brms"))
install.packages(c("rstan", "StanHeaders", "brms"))

Unfortunately, it did not remove the issue. I still get the error ouput below, plus now, I again get the command-not-found output again (sh: clang++ -mmacosx-version-min=10.13: command not found).

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='file58b171884753.so' OBJECTS='file58b171884753.o'

make would use
clang++ -mmacosx-version-min=10.13 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/unsupported"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/BH/include" -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/src/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/"  -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppParallel/include/"  -I"/Library/Frameworks/R.framework/Versions/4.0/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.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp'  -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1   -I/usr/local/include   -fPIC  -Wall -g -O2  -c file58b171884753.cpp -o file58b171884753.o
if test  "zfile58b171884753.o" != "z"; then \
	  echo clang++ -mmacosx-version-min=10.13 -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/usr/local/lib -o file58b171884753.so file58b171884753.o  /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/lib//libStanServices.a -L'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/lib/' -lStanHeaders -L'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppParallel/lib/' -ltbb -ltbbmalloc -ltbbmalloc_proxy  -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation; \
	  clang++ -mmacosx-version-min=10.13 -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/usr/local/lib -o file58b171884753.so file58b171884753.o  /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/lib//libStanServices.a -L'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/lib/' -lStanHeaders -L'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppParallel/lib/' -ltbb -ltbbmalloc -ltbbmalloc_proxy  -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation; \
	fi
Error in compileCode(f, code, language = language, verbose = verbose) : 
  In file included from <built-in>:1:In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13:In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Dense:1:In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/RcppEigen/include/Eigen/Core:82:In file included from /usr/local/clang7/include/c++/v1/new:91:In file included from /usr/local/clang7/include/c++/v1/exception:82:In file included from /usr/local/clang7/include/c++/v1/cstdlib:86:/usr/local/clang7/include/c++/v1/stdlib.h:94:15: fatal error: 'stdlib.h' file not found#include_next <stdlib.h>              ^~~~~~~~~~1 error generated.make: *** [file58b171884753.o] Error 1
In addition: Warning messages:
1: Rows containing NAs were excluded from the model. 
2: In system2(CXX, args = ARGS) : error in running command
3: In file.remove(c(unprocessed, processed)) :
  cannot remove file '/var/folders/j9/ttvwqt113mg7bvr4lv409jbh0000gn/T//RtmpOszTnI/file58b14d3bb8ce.stan', reason 'No such file or directory'
Error in sink(type = "output") : invalid connection

During package installation I chose to install the packages without compilation, maybe that makes a difference? Also, I was notified that my library folder is not called ‘library’, but ‘lib’ (or it was the other way around, sorry, I do not remember), maybe that might be a problem?

Best wishes

I‘m very sorry, but I‘m at my wit‘s end…

Maybe somebody else knows?

Thank you anyway for your time and effort!

If somebody else sees this:
Maybe the problem is that the following file is not found?

In file included from /usr/local/clang7/include/c++/v1/cstdlib:86:/usr/local/clang7/include/c++/v1/stdlib.h:94:15: fatal error: 'stdlib.h' file not found

However, unfortunately I do not know anything about how to tackle this issue, so any ideas are appreciated.

Hmm, try xcode-select --install in the terminal (not in R).

1 Like

Hello Torkar,
thank you for your answer. I tried that (and think that I might have already tried this at some point), but I get:

xcode-select: error: command line tools are already installed, use "Software Update" to install updates