I have been unable to run brms models after updating Xcode to the latest version (15.4) on Mac OSX.
Here is an example of a model I tried to run:
mfrs_sk_ds4a.ml <-
brm(data = dat3,
family = skew_normal,
bf(thr ~ 0 + Intercept + (1|ear) + race + sex + (1|prt) + (1|c|freq) + (1|freq:race:sex), sigma ~ 1|c|freq, alpha ~ 1|freq),
prior = priors_skds4a,
iter = 5000, warmup = 1000, chains = 4, cores = getOption("mc.cores", 8), init= "0", control= list(adapt_delta=0.99, max_treedepth=15), backend = "rstan", thin=1, threads = threading(2),
seed = 345786,
file = NULL)
When I try to run the model, get the following error message:
…
Error in compileCode(f, code, language = language, verbose = verbose) :
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__exception/exception_ptr.h:26:33: note: definition of ‘std::exception_ptr’ is not complete until the closing '}'class _LIBCPP_EXPORTED_FROM_ABI exception_ptr { ^fatal error: too many errors emitted, stopping now [-ferror-limit=]20 errors generated.make: *** [file589c82bde2f.o] Error 1
Error in sink(type = “output”) : invalid connection
…
Please also provide the following information in addition to your question:
- Operating System: Mac OSX Sonoma 14.5
- brms Version: 2.21.0
I tried reinstalling rstan and StanHeaders but it did not solve the issue.
Any help would be much appreciated. Thanks,
I have tried the following and determined that the problem has nothing to do with brms. I have tried running the example code “example(stan_model, package = “rstan”, run.dontrun = TRUE)” from the R console and I get the following error message:
…
Compilation ERROR, function(s)/method(s) not created!
Error in compileCode(f, code, language = language, verbose = verbose) :
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__exception/exception_ptr.h:26:33: note: definition of ‘std::exception_ptr’ is not complete until the closing '}'class _LIBCPP_EXPORTED_FROM_ABI exception_ptr { ^fatal error: too many errors emitted, stopping now [-ferror-limit=]20 errors generated.make: *** [file1129b0d61e3.o] Error 1
I have tried the following: 1. clearing Xcode cahe , 2. uninstalling/installing Xcode Command Line Tools, 3. uninstalling/installing rstan, 4. uninstalling/installing R and XQuartz. Installations seem to have completed with no errors, but none of these potential solutions worked.
Not sure what to do what I can try next. Does anyone else have trouble running Stan code with Xcode 15.4? (Forgot to earlier mention my computer is an M1 MacBook Pro). Thanks
Can you try switching your system to use the Command Line tools (instead of Xcode) as the toolchain provider?
Open up a terminal and run:
sudo xcode-select -s /Library/Developer/CommandLineTools
Then restart your R session and try again?
The command line tools have been working without issue for me on a MacOS 14.5 M1, but I’ll have a look at debugging the xcode build tools later this week and see what we might need to change for compatibility
I’ve now installed XCode 15.4 and set it as the default toolchain, and I still can’t reproduce your error.
Are you able install packages from source normally? For example, does the following succeed
install.packages("Rcpp", type="source")
Additionally, can you post the output from the following command (use R to compile empty .cpp file to test compiler):
system("touch foo.cpp && R CMD SHLIB foo.cpp")
Hi Andrew,
I ran the code from Terminal as you suggested, restarted the R session and run the example code again. This is the error message I get:
.
Program code here (verbose, did not include it)
.
.
make cmd is
make -f ‘/Library/Frameworks/R.framework/Resources/etc/Makeconf’ -f ‘/Library/Frameworks/R.framework/Resources/share/make/shlib.mk’ CXX=‘(CXX17) (CXX17STD)’ CXXFLAGS=‘(CXX17FLAGS)' CXXPICFLAGS='(CXX17PICFLAGS)’ SHLIB_LDFLAGS=‘(SHLIB_CXX17LDFLAGS)' SHLIB_LD='(SHLIB_CXX17LD)’ SHLIB=‘file1b18d748f8e.so’ OBJECTS=‘file1b18d748f8e.o’
make would use
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Users/valterciocca/Library/R/arm64/4.4/library/Rcpp/include/" -I"/Users/valterciocca/Library/R/arm64/4.4/library/RcppEigen/include/" -I"/Users/valterciocca/Library/R/arm64/4.4/library/RcppEigen/include/unsupported" -I"/Users/valterciocca/Library/R/arm64/4.4/library/BH/include" -I"/Users/valterciocca/Library/R/arm64/4.4/library/StanHeaders/include/src/" -I"/Users/valterciocca/Library/R/arm64/4.4/library/StanHeaders/include/" -I"/Users/valterciocca/Library/R/arm64/4.4/library/RcppParallel/include/" -I"/Users/valterciocca/Library/R/arm64/4.4/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 -D_HAS_AUTO_PTR_ETC=0 -include ‘/Users/valterciocca/Library/R/arm64/4.4/library/StanHeaders/include/stan/math/prim/fun/Eigen.hpp’ -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1 -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c file1b18d748f8e.cpp -o file1b18d748f8e.o
if test “zfile1b18d748f8e.o” != “z”; then
echo clang++ -arch arm64 -std=gnu++17 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -L"/Library/Frameworks/R.framework/Resources/lib" -L/opt/R/arm64/lib -o file1b18d748f8e.so file1b18d748f8e.o ‘/Users/valterciocca/Library/R/arm64/4.4/library/rstan/lib//libStanServices.a’ -L’/Users/valterciocca/Library/R/arm64/4.4/library/StanHeaders/lib/’ -lStanHeaders -L’/Users/valterciocca/Library/R/arm64/4.4/library/RcppParallel/lib/’ -ltbb -L/Users/valterciocca/Library/R/arm64/4.4/library/RcppParallel/lib -ltbb -ltbbmalloc -F/Library/Frameworks/R.framework/… -framework R -Wl,-framework -Wl,CoreFoundation;
clang++ -arch arm64 -std=gnu++17 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -L"/Library/Frameworks/R.framework/Resources/lib" -L/opt/R/arm64/lib -o file1b18d748f8e.so file1b18d748f8e.o ‘/Users/valterciocca/Library/R/arm64/4.4/library/rstan/lib//libStanServices.a’ -L’/Users/valterciocca/Library/R/arm64/4.4/library/StanHeaders/lib/’ -lStanHeaders -L’/Users/valterciocca/Library/R/arm64/4.4/library/RcppParallel/lib/’ -ltbb -L/Users/valterciocca/Library/R/arm64/4.4/library/RcppParallel/lib -ltbb -ltbbmalloc -F/Library/Frameworks/R.framework/… -framework R -Wl,-framework -Wl,CoreFoundation;
fi
ERROR(s) during compilation: source code errors or compiler configuration errors!
Program source:
Program code here (verbose, did not include it)
.
.
Compilation ERROR, function(s)/method(s) not created!
Error in compileCode(f, code, language = language, verbose = verbose) :
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__exception/exception_ptr.h:26:33: note: definition of ‘std::exception_ptr’ is not complete until the closing '}'class _LIBCPP_EXPORTED_FROM_ABI exception_ptr { ^fatal error: too many errors emitted, stopping now [-ferror-limit=]20 errors generated.make: *** [file1b18d748f8e.o] Error 1
I appreciate very much that you are taking the time to look into this problem. Thank you!
Hi again, Andrew.
Here is the output I get when I do as you have suggested:
install.packages(“Rcpp”, type=“source”)
Installing package into ‘/Users/valterciocca/Library/R/arm64/4.4/library’
(as ‘lib’ is unspecified)
trying URL ‘https://ftp.osuosl.org/pub/cran/src/contrib/Rcpp_1.0.12.tar.gz’
Content type ‘application/x-gzip’ length 3430494 bytes (3.3 MB)
==================================================
downloaded 3.3 MB
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I…/inst/include/ -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c api.cpp -o api.o
The downloaded source packages are in
‘/private/var/folders/hm/n4y8q4ks0x35w5zrh2r4bc_h0000gp/T/Rtmp5xdUXw/downloaded_packages’
Warning message:
In install.packages(“Rcpp”, type = “source”) :
installation of package ‘Rcpp’ had non-zero exit status
Then, when I run:
system(“touch foo.cpp && R CMD SHLIB foo.cpp”)
I get:
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c foo.cpp -o foo.o
clang++ -arch arm64 -std=gnu++17 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o foo.so foo.o -F/Library/Frameworks/R.framework/… -framework R -Wl,-framework -Wl,CoreFoundation
Thank you, Valter
According to this output Rcpp
failed to build from source:
Warning message:
In install.packages(“Rcpp”, type = “source”) :
installation of package ‘Rcpp’ had non-zero exit status
Which indicates a broader (not Stan-related) issue with your R/toolchain setup. Can you post the full output log from the Rcpp
installation attempt?
Hi Andrew,
I tried to install Rcpp again, with setting verbose=TRUE (this is what you meant by full output log, right?). The output is the following:
Installing package into ‘/Users/valterciocca/Library/R/arm64/4.4/library’
(as ‘lib’ is unspecified)
system (cmd0): /Library/Frameworks/R.framework/Resources/bin/R CMD INSTALL
trying URL ‘https://ftp.osuosl.org/pub/cran/src/contrib/Rcpp_1.0.12.tar.gz’
Content type ‘application/x-gzip’ length 3430494 bytes (3.3 MB)
downloaded 3.3 MB
foundpkgs: Rcpp, /var/folders/hm/n4y8q4ks0x35w5zrh2r4bc_h0000gp/T//Rtmp5xdUXw/downloaded_packages/Rcpp_1.0.12.tar.gz
files: /var/folders/hm/n4y8q4ks0x35w5zrh2r4bc_h0000gp/T//Rtmp5xdUXw/downloaded_packages/Rcpp_1.0.12.tar.gz
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I…/inst/include/ -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c api.cpp -o api.o
The downloaded source packages are in
‘/private/var/folders/hm/n4y8q4ks0x35w5zrh2r4bc_h0000gp/T/Rtmp5xdUXw/downloaded_packages’
Warning message:
In install.packages(“Rcpp”, type = “source”, verbose = TRUE) :
installation of package ‘Rcpp’ had non-zero exit status
"
Thank you
(sorry about the formatting of the first few lilnes. Not sure why it happened)
That’s a bit odd, there should much more output (including an error). I wonder if your installation is suppressing stderr
for some reason (like with sink()
or similar). Let’s try just using the command line to see if we can get more informative results.
Can you open a terminal and run:
curl https://cran.r-project.org/src/contrib/Rcpp_1.0.12.tar.gz -o Rcpp_1.0.12.tar.gz
R CMD INSTALL Rcpp_1.0.12.tar.gz
And post the output?
Additionally, do you have any other toolchains installed (e.g., through Homebrew/Macports)?
Here is the output from Terminal:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3350k 100 3350k 0 0 1682k 0 0:00:01 0:00:01 --:–:-- 1682k
- installing to library ‘/Users/valterciocca/Library/R/arm64/4.4/library’
- installing source package ‘Rcpp’ …
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
using C++ compiler: ‘Apple clang version 15.0.0 (clang-1500.3.9.4)’
using SDK: ‘MacOSX14.4.sdk’
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I…/inst/include/ -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c api.cpp -o api.o
In file included from api.cpp:26:
In file included from …/inst/include/Rcpp.h:27:
In file included from …/inst/include/RcppCommon.h:30:
In file included from …/inst/include/Rcpp/r/headers.h:62:
In file included from …/inst/include/Rcpp/platform/compiler.h:100:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:321:5: error: tried including <math.h> but didn’t find libc++'s <math.h> header. This usually means that your header search paths are not configured properly. The header search paths should contain the C++ Standard Library headers before any C Standard Library, and you are probably using compiler flags that make that not be the case.
error tried including <math.h> but didn’t find libc++'s <math.h> header. \
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:588:17: error: expected unqualified-id
return std::isnan(__lcpp_x);
^
/usr/local/include/math.h:166:5: note: expanded from macro ‘isnan’
( sizeof(x) == sizeof(float) ? __inline_isnanf((float)(x))
^
In file included from api.cpp:26:
In file included from …/inst/include/Rcpp.h:27:
In file included from …/inst/include/RcppCommon.h:30:
In file included from …/inst/include/Rcpp/r/headers.h:62:
In file included from …/inst/include/Rcpp/platform/compiler.h:100:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:608:17: error: expected unqualified-id
return std::isinf(__lcpp_x);
^
/usr/local/include/math.h:161:5: note: expanded from macro ‘isinf’
( sizeof(x) == sizeof(float) ? __inline_isinff((float)(x))
^
In file included from api.cpp:26:
In file included from …/inst/include/Rcpp.h:27:
In file included from …/inst/include/RcppCommon.h:30:
In file included from …/inst/include/Rcpp/r/headers.h:62:
In file included from …/inst/include/Rcpp/platform/compiler.h:100:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:724:15: error: no template named ‘numeric_limits’
return -numeric_limits<_Tp>::infinity();
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:728:14: error: no template named ‘numeric_limits’
return numeric_limits<_Tp>::infinity();
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:731:14: error: no template named ‘numeric_limits’
return numeric_limits<_Tp>::quiet_NaN();
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:735:19: error: no template named ‘numeric_limits’
while (__x >= numeric_limits<_Tp>::radix) {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:736:14: error: no template named ‘numeric_limits’
__x /= numeric_limits<_Tp>::radix;
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:759:14: error: no template named ‘numeric_limits’
return numeric_limits<_Tp>::quiet_NaN();
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:763:16: error: no template named ‘numeric_limits’
__mult = numeric_limits<_Tp>::radix;
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:768:17: error: no template named ‘numeric_limits’
__mult /= numeric_limits<_Tp>::radix;
^
In file included from api.cpp:26:
In file included from …/inst/include/Rcpp.h:27:
In file included from …/inst/include/RcppCommon.h:30:
In file included from …/inst/include/Rcpp/r/headers.h:62:
In file included from …/inst/include/Rcpp/platform/compiler.h:100:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:834:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:425:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__type_traits/add_pointer.h:17:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__type_traits/remove_reference.h:13:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cstddef:46:5: error: tried including <stddef.h> but didn’t find libc++'s <stddef.h> header. This usually means that your header search paths are not configured properly. The header search paths should contain the C++ Standard Library headers before any C Standard Library, and you are probably using compiler flags that make that not be the case.
error tried including <stddef.h> but didn’t find libc++'s <stddef.h> header. \
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cstddef:59:9: error: no member named ‘nullptr_t’ in the global namespace
using ::nullptr_t;
^
In file included from api.cpp:26:
In file included from …/inst/include/Rcpp.h:27:
In file included from …/inst/include/RcppCommon.h:30:
In file included from …/inst/include/Rcpp/r/headers.h:62:
In file included from …/inst/include/Rcpp/platform/compiler.h:100:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:834:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:456:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__type_traits/is_compound.h:14:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__type_traits/is_fundamental.h:14:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__type_traits/is_null_pointer.h:26:28: error: use of undeclared identifier ‘nullptr_t’; did you mean ‘nullptr’?
struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__type_traits/is_null_pointer.h:26:28: error: template argument for template type parameter must be a type
struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
^~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__type_traits/is_null_pointer.h:23:17: note: template parameter is declared here
template
^
In file included from api.cpp:26:
In file included from …/inst/include/Rcpp.h:27:
In file included from …/inst/include/RcppCommon.h:30:
In file included from …/inst/include/Rcpp/r/headers.h:62:
In file included from …/inst/include/Rcpp/platform/compiler.h:100:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:834:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:508:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__type_traits/is_trivially_copyable.h:14:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cstdint:149:5: error: tried including <stdint.h> but didn’t find libc++'s <stdint.h> header. This usually means that your header search paths are not configured properly. The header search paths should contain the C++ Standard Library headers before any C Standard Library, and you are probably using compiler flags that make that not be the case.
error tried including <stdint.h> but didn’t find libc++'s <stdint.h> header. \
^
In file included from api.cpp:26:
In file included from …/inst/include/Rcpp.h:27:
In file included from …/inst/include/RcppCommon.h:30:
In file included from …/inst/include/Rcpp/r/headers.h:62:
In file included from …/inst/include/Rcpp/platform/compiler.h:153:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/unordered_map:592:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__hash_table:18:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/hash.h:28:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/cstring:66:5: error: tried including <string.h> but didn’t find libc++'s <string.h> header. This usually means that your header search paths are not configured properly. The header search paths should contain the C++ Standard Library headers before any C Standard Library, and you are probably using compiler flags that make that not be the case.
error tried including <string.h> but didn’t find libc++'s <string.h> header. \
^
In file included from api.cpp:26:
In file included from …/inst/include/Rcpp.h:27:
In file included from …/inst/include/RcppCommon.h:30:
In file included from …/inst/include/Rcpp/r/headers.h:62:
In file included from …/inst/include/Rcpp/platform/compiler.h:153:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/unordered_map:592:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__hash_table:18:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/hash.h:646:34: error: use of undeclared identifier ‘nullptr_t’; did you mean ‘nullptr’?
struct _LIBCPP_TEMPLATE_VIS hash<nullptr_t>
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/hash.h:646:34: error: template argument for template type parameter must be a type
struct _LIBCPP_TEMPLATE_VIS hash<nullptr_t>
^~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__functional/hash.h:638:17: note: template parameter is declared here
template
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [api.o] Error 1
ERROR: compilation failed for package ‘Rcpp’
- removing ‘/Users/valterciocca/Library/R/arm64/4.4/library/Rcpp’
- restoring previous ‘/Users/valterciocca/Library/R/arm64/4.4/library/Rcpp’
I do not have any other toolchain installed as far as I can tell.
Thank you
Ah yep there it is, you have c++ header files for another toolchain in your /usr/local/include
folder:
/usr/local/include/math.h:166:5: note: expanded from macro ‘isnan’
Great. How do I fix this? (sorry, my knowledge is rather limited in this regard)
Thank you
The fastest solution is to delete all files in your /usr/local/include
folder - but you should only do this if you don’t have any other dependencies or programs using files from there
Hi Andrew,
I made some good progress following the solution you suggested. I removed all files from /usr/local/include and then I ran:
- ‘curl https://cran.r-project.org/src/contrib/Rcpp_1.0.12.tar.gz -o Rcpp_1.0.12.tar.gz’
from Terminal. This time it worked (output:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3350k 100 3350k 0 0 1662k 0 0:00:02 0:00:02 --:–:-- 1662k
). No error messages. I checked that installation worked by running ‘gcc’ (output, as expected: clang: error: no input files)
Then I ran ‘system(“touch foo.cpp && R CMD SHLIB foo.cpp”)’ from the R Console. All seems fine here too (output:
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c foo.cpp -o foo.o
clang++ -arch arm64 -std=gnu++17 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o foo.so foo.o -F/Library/Frameworks/R.framework/… -framework R -Wl,-framework -Wl,CoreFoundation)
- From the R Console, I ran ‘library (rstan)’ (output:
Loading required package: StanHeaders
rstan version 2.35.0.9000 (Stan version 2.35.0)
For execution on a local, multicore CPU with excess RAM we recommend calling
options(mc.cores = parallel::detectCores()).
To avoid recompilation of unchanged Stan programs, we recommend calling
rstan_options(auto_write = TRUE)
For within-chain threading using reduce_sum()
or map_rect()
Stan functions,
change threads_per_chain
option:
rstan_options(threads_per_chain = 1)
).
Now, ‘example(stan_model, package = “rstan”, run.dontrun = TRUE)’,
works without error messages.
- I then loaded RStudio and tried running a brms model such as the one as posted in the original post. The model with the option (backend = “cmstanr”) compiles without issues. However, when I set the ‘backend’ option to ‘rstan’, the model does not compile and aborts with the following error message:
Compiling Stan program…
Start sampling
starting worker pid=21095 on localhost:11964 at 17:13:16.444
starting worker pid=21108 on localhost:11964 at 17:13:16.565
starting worker pid=21121 on localhost:11964 at 17:13:16.673
starting worker pid=21134 on localhost:11964 at 17:13:16.784
SAMPLING FOR MODEL ‘anon_model’ NOW (CHAIN 1).
Chain 1:
Chain 1: Gradient evaluation took 0.000781 seconds
Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 7.81 seconds.
Chain 1: Adjust your expectations accordingly!
Chain 1:
Chain 1:
TBB Warning: Exact exception propagation is requested by application but the linked library is built without support for it
I realize that at this point this might be an issue with brms, but if you have any idea why I cannot run the model with rstan that would be great.
Thank you again for your help! At least now I can get back to modelling, though I have to stick with cmdstanr.