I don’t have an M1, so take this with a grain of salt, but a couple of points:
You can and probably should use the Apple-supplied clang, not the homebrew/llvm version.
After an upgrade, you usually have to upgrade to the latest version of the Xcode command-line tools, either by launching Xcode and/or running xcode-select --install.
Thanks for the suggestion. Unfortunately, that is exactly what I have done and still not working. -I removed homebrew entirely and reinstalled Xcode and the latest version of the command-line tools. And this is my $PATH setting:
Can you run the following just to check whether this is an issue with cmdstan or cmdstanr?
git clone --recursive https://github.com/stan-dev/cmdstan
cd cmdstan
make build
make examples/bernoulli/bernoulli
This seems to be a pretty common problem for macs across C++ projects. the stackoverflow post below may also be helpful (though be careful with copy pasting some of the code in the answers as that is messing with some stuff in the system. The second answer to check for CPATH in .bashrc could be a culprit)
curl -L https://github.com/stan-dev/stanc3/releases/download/nightly/mac-stanc -o bin/stanc --retry 5 --retry-delay 10
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 617 100 617 0 0 2134 0 --:--:-- --:--:-- --:--:-- 2127
100 10.6M 100 10.6M 0 0 10.5M 0 0:00:01 0:00:01 --:--:-- 10.5M
chmod +x bin/stanc
clang++ -std=c++1y -Wno-unknown-warning-option -Wno-tautological-compare -Wno-sign-compare -D_REENTRANT -Wno-ignored-attributes -I stan/lib/stan_math/lib/tbb_2020.3/include -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.75.0 -I stan/lib/stan_math/lib/sundials_5.7.0/include -DBOOST_DISABLE_ASSERTS -c -fvisibility=hidden -o bin/cmdstan/stansummary.o src/cmdstan/stansummary.cpp
In file included from src/cmdstan/stansummary.cpp:1:
In file included from src/cmdstan/stansummary_helper.hpp:4:
In file included from stan/src/stan/mcmc/chains.hpp:4:
In file included from stan/src/stan/io/stan_csv_reader.hpp:4:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/algorithm/string.hpp:23:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/algorithm/string/split.hpp:16:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/algorithm/string/iter_find.hpp:27:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/algorithm/string/find_iterator.hpp:24:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/algorithm/string/detail/find_iterator.hpp:18:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/function.hpp:30:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/function/detail/prologue.hpp:17:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/function/function_base.hpp:21:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/type_index.hpp:29:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/type_index/stl_type_index.hpp:47:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/container_hash/hash.hpp:22:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/container_hash/detail/hash_float.hpp:14:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/container_hash/detail/float_functions.hpp:14:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/config/no_tr1/cmath.hpp:21:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:321:9: error: no member named 'signbit' in the global namespace
using ::signbit;
~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:322:9: error: no member named 'fpclassify' in the global namespace
using ::fpclassify;
~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:323:9: error: no member named 'isfinite' in the global namespace
using ::isfinite;
~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:324:9: error: no member named 'isinf' in the global namespace
using ::isinf;
~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:325:9: error: no member named 'isnan' in the global namespace
using ::isnan;
~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:326:9: error: no member named 'isnormal' in the global namespace
using ::isnormal;
~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:327:7: error: no member named 'isgreater' in the global namespace; did you mean '::std::greater'?
using ::isgreater;
^~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:738:29: note: '::std::greater' declared here
struct _LIBCPP_TEMPLATE_VIS greater : binary_function<_Tp, _Tp, bool>
^
In file included from src/cmdstan/stansummary.cpp:1:
In file included from src/cmdstan/stansummary_helper.hpp:4:
In file included from stan/src/stan/mcmc/chains.hpp:4:
In file included from stan/src/stan/io/stan_csv_reader.hpp:4:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/algorithm/string.hpp:23:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/algorithm/string/split.hpp:16:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/algorithm/string/iter_find.hpp:27:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/algorithm/string/find_iterator.hpp:24:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/algorithm/string/detail/find_iterator.hpp:18:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/function.hpp:30:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/function/detail/prologue.hpp:17:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/function/function_base.hpp:21:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/type_index.hpp:29:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/type_index/stl_type_index.hpp:47:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/container_hash/hash.hpp:22:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/container_hash/detail/hash_float.hpp:14:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/container_hash/detail/float_functions.hpp:14:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/config/no_tr1/cmath.hpp:21:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:328:7: error: no member named 'isgreaterequal' in the global namespace; did you mean '::std::greater_equal'?
using ::isgreaterequal;
^~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/functional:767:29: note: '::std::greater_equal' declared here
struct _LIBCPP_TEMPLATE_VIS greater_equal : binary_function<_Tp, _Tp, bool>
^
In file included from src/cmdstan/stansummary.cpp:1:
In file included from src/cmdstan/stansummary_helper.hpp:4:
In file included from stan/src/stan/mcmc/chains.hpp:4:
In file included from stan/src/stan/io/stan_csv_reader.hpp:4:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/algorithm/string.hpp:23:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/algorithm/string/split.hpp:16:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/algorithm/string/iter_find.hpp:27:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/algorithm/string/find_iterator.hpp:24:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/algorithm/string/detail/find_iterator.hpp:18:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/function.hpp:30:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/function/detail/prologue.hpp:17:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/function/function_base.hpp:21:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/type_index.hpp:29:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/type_index/stl_type_index.hpp:47:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/container_hash/hash.hpp:22:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/container_hash/detail/hash_float.hpp:14:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/container_hash/detail/float_functions.hpp:14:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/config/no_tr1/cmath.hpp:21:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:329:7: error: no member named 'isless' in the global namespace; did you mean 'boost::is_less'?
using ::isless;
^~
stan/lib/stan_math/lib/boost_1.75.0/boost/algorithm/string/compare.hpp:191:22: note: 'boost::is_less' declared here
using algorithm::is_less;
^
In file included from src/cmdstan/stansummary.cpp:1:
In file included from src/cmdstan/stansummary_helper.hpp:4:
In file included from stan/src/stan/mcmc/chains.hpp:4:
In file included from stan/src/stan/io/stan_csv_reader.hpp:4:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/algorithm/string.hpp:23:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/algorithm/string/split.hpp:16:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/algorithm/string/iter_find.hpp:27:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/algorithm/string/find_iterator.hpp:24:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/algorithm/string/detail/find_iterator.hpp:18:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/function.hpp:30:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/function/detail/prologue.hpp:17:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/function/function_base.hpp:21:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/type_index.hpp:29:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/type_index/stl_type_index.hpp:47:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/container_hash/hash.hpp:22:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/container_hash/detail/hash_float.hpp:14:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/container_hash/detail/float_functions.hpp:14:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/config/no_tr1/cmath.hpp:21:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:330:9: error: no member named 'islessequal' in the global namespace
using ::islessequal;
~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:331:9: error: no member named 'islessgreater' in the global namespace
using ::islessgreater;
~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:332:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:333:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
~~^
In file included from src/cmdstan/stansummary.cpp:1:
In file included from src/cmdstan/stansummary_helper.hpp:4:
In file included from stan/src/stan/mcmc/chains.hpp:4:
In file included from stan/src/stan/io/stan_csv_reader.hpp:5:
In file included from stan/lib/stan_math/stan/math/prim.hpp:10:
In file included from stan/lib/stan_math/stan/math/prim/core.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/core/init_threadpool_tbb.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/err/invalid_argument.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/meta.hpp:176:
In file included from stan/lib/stan_math/stan/math/prim/meta/append_return_type.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/fun/Eigen.hpp:22:
In file included from stan/lib/stan_math/lib/eigen_3.3.9/Eigen/Dense:1:
In file included from stan/lib/stan_math/lib/eigen_3.3.9/Eigen/Core:374:
stan/lib/stan_math/lib/eigen_3.3.9/Eigen/src/Core/MathFunctions.h:722:16: error: no member named 'isfinite' in namespace 'std'
using std::isfinite;
~~~~~^
stan/lib/stan_math/lib/eigen_3.3.9/Eigen/src/Core/MathFunctions.h:737:16: error: no member named 'isinf' in namespace 'std'
using std::isinf;
~~~~~^
stan/lib/stan_math/lib/eigen_3.3.9/Eigen/src/Core/MathFunctions.h:752:16: error: no member named 'isnan' in namespace 'std'
using std::isnan;
~~~~~^
In file included from src/cmdstan/stansummary.cpp:1:
In file included from src/cmdstan/stansummary_helper.hpp:4:
In file included from stan/src/stan/mcmc/chains.hpp:4:
In file included from stan/src/stan/io/stan_csv_reader.hpp:5:
In file included from stan/lib/stan_math/stan/math/prim.hpp:10:
In file included from stan/lib/stan_math/stan/math/prim/core.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/core/init_threadpool_tbb.hpp:6:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast.hpp:32:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/try_lexical_convert.hpp:44:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical.hpp:54:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical_streams.hpp:63:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/inf_nan.hpp:34:
stan/lib/stan_math/lib/boost_1.75.0/boost/math/special_functions/sign.hpp:30:17: error: no member named 'signbit' in namespace 'std'; did you mean simply 'signbit'?
return (std::signbit)(x) ? 1 : 0;
^~~~~~~~~~~~
signbit
stan/lib/stan_math/lib/boost_1.75.0/boost/math/special_functions/math_fwd.hpp:891:8: note: 'signbit' declared here
int signbit BOOST_NO_MACRO_EXPAND(T x);
^
In file included from src/cmdstan/stansummary.cpp:1:
In file included from src/cmdstan/stansummary_helper.hpp:4:
In file included from stan/src/stan/mcmc/chains.hpp:4:
In file included from stan/src/stan/io/stan_csv_reader.hpp:5:
In file included from stan/lib/stan_math/stan/math/prim.hpp:10:
In file included from stan/lib/stan_math/stan/math/prim/core.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/core/init_threadpool_tbb.hpp:6:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast.hpp:32:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/try_lexical_convert.hpp:44:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical.hpp:54:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical_streams.hpp:63:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/inf_nan.hpp:35:
stan/lib/stan_math/lib/boost_1.75.0/boost/math/special_functions/fpclassify.hpp:155:12: error: no member named 'fpclassify' in namespace 'std'; did you mean simply 'fpclassify'?
return (std::fpclassify)(t);
^~~~~~~~~~~~~~~
fpclassify
stan/lib/stan_math/lib/boost_1.75.0/boost/math/special_functions/math_fwd.hpp:876:8: note: 'fpclassify' declared here
int fpclassify BOOST_NO_MACRO_EXPAND(T t);
^
In file included from src/cmdstan/stansummary.cpp:1:
In file included from src/cmdstan/stansummary_helper.hpp:4:
In file included from stan/src/stan/mcmc/chains.hpp:4:
In file included from stan/src/stan/io/stan_csv_reader.hpp:5:
In file included from stan/lib/stan_math/stan/math/prim.hpp:10:
In file included from stan/lib/stan_math/stan/math/prim/core.hpp:4:
In file included from stan/lib/stan_math/stan/math/prim/core/init_threadpool_tbb.hpp:6:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast.hpp:32:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/try_lexical_convert.hpp:44:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical.hpp:54:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/converter_lexical_streams.hpp:63:
In file included from stan/lib/stan_math/lib/boost_1.75.0/boost/lexical_cast/detail/inf_nan.hpp:35:
stan/lib/stan_math/lib/boost_1.75.0/boost/math/special_functions/fpclassify.hpp:314:17: error: no member named 'isfinite' in namespace 'std'; did you mean simply 'isfinite'?
return (std::isfinite)(x);
^~~~~~~~~~~~~
isfinite
stan/lib/stan_math/lib/boost_1.75.0/boost/math/special_functions/math_fwd.hpp:879:9: note: 'isfinite' declared here
bool isfinite BOOST_NO_MACRO_EXPAND(T z);
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [bin/cmdstan/stansummary.o] Error 1
The update to MacOS 11.3 and Xcode 12.5, with Command Line Tools, broke
clang++ 11: It can not find system headers such as wchar.h, it seems.
Unclear with workarounds. Curiously, g++ 10 works.
I’ll check that out - but I do have my old computer (I suspected there might be problems, so I held onto that, just in case). My guess this is kind of a big deal, so they should have a fix for this soon, right? Thanks for all of your efforts.
Did you check out the two answers in the stackoverflow post above? It looks like it’s a weird thing that can be caused by something in your .bashrc or bad linking by Apple in the includes file.
Sorry I can’t be more help here as I don’t own a Mac 😑 but if you search for those error messages on stackoverflow it seems like a good few Qs come up related. My guess is that this will effect any R packages with C inside of them that use the cmath header
I did see that, but I do not believe there is a .bashrc file anymore, only a .zshrc file, which currently only sets my $PATH. And mucking around with linking in includes files is above my pay grade.
I have finally had success. I found a solution here, on the rstan development site no less.
Essentially the solution that worked for me was to install Xcode (I installed the latest version 12.5), but without separately installing the CommandLineTools using xcode-select --install. Again, I did not install CommandLineTools using xcode-select --install. Apparently, the Xcode installation includes an installation of the tools in /Applications/Xcode.app/Contents/Developer. I don’t think I needed to this, but to be safe I made sure the path was set to this directory by executing sudo xcode-select --switch /Applications/Xcode.app.
After that, within Rstudio I installed cmdstan with cmdstanr::install_cmdstan(). And I was able to compile my test stan code and estimate a model.
Thank you for all of your efforts to help out. I hope that others find this useful if they run into the same problem.