in order to get the C++ toolchain setup on Catalina, then to open it you apparently have to hold down Ctrl while clicking on the installer file that you downloaded. At that point it should look like
and clicking Open will get it going.
You probably need to have R 3.6 or later for things to work smoothly.
Also, you will probably have to install rstan and related packages from source, via
install.packages(c("StanHeaders", "rstan"), type = "source")
and similarly for rstanarm and other R packages that come with compiled Stan programs.
I am on macOS Catalina 10.15.3
and using R version 3.6.3 (2020-02-29)
I followed the instructions here, installing rtools and then running install.packages(c(āStanHeadersā, āstanā), type = āsourceā).
However, when I now try to install RStan (by calling install.packages(c(ārstanā), type = āsourceā)), I get the following error:
In file included from pointer-tools.cpp:2:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include/boost/random/additive_combine.hpp:22:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include/boost/config.hpp:57:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include/boost/config/platform/macos.hpp:28:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include/boost/config/detail/posix_features.hpp:18:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:655:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/gethostuuid.h:39:17: error: C++ requires a type specifier for all declarations
int gethostuuid(uuid_t, const struct timespec *) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_NA);
^
In file included from pointer-tools.cpp:2:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include/boost/random/additive_combine.hpp:22:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include/boost/config.hpp:57:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include/boost/config/platform/macos.hpp:28:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include/boost/config/detail/posix_features.hpp:18:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:662:27: error: unknown type name 'uuid_t'; did you mean 'uid_t'?
int getsgroups_np(int *, uuid_t);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types/_uid_t.h:31:31: note: 'uid_t' declared here
typedef __darwin_uid_t uid_t;
^
In file included from pointer-tools.cpp:2:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include/boost/random/additive_combine.hpp:22:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include/boost/config.hpp:57:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include/boost/config/platform/macos.hpp:28:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include/boost/config/detail/posix_features.hpp:18:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:664:27: error: unknown type name 'uuid_t'; did you mean 'uid_t'?
int getwgroups_np(int *, uuid_t);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types/_uid_t.h:31:31: note: 'uid_t' declared here
typedef __darwin_uid_t uid_t;
^
In file included from pointer-tools.cpp:2:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include/boost/random/additive_combine.hpp:22:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include/boost/config.hpp:57:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include/boost/config/platform/macos.hpp:28:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include/boost/config/detail/posix_features.hpp:18:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:727:31: error: unknown type name 'uuid_t'; did you mean 'uid_t'?
int setsgroups_np(int, const uuid_t);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types/_uid_t.h:31:31: note: 'uid_t' declared here
typedef __darwin_uid_t uid_t;
^
In file included from pointer-tools.cpp:2:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include/boost/random/additive_combine.hpp:22:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include/boost/config.hpp:57:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include/boost/config/platform/macos.hpp:28:
In file included from /Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include/boost/config/detail/posix_features.hpp:18:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:729:31: error: unknown type name 'uuid_t'; did you mean 'uid_t'?
int setwgroups_np(int, const uuid_t);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types/_uid_t.h:31:31: note: 'uid_t' declared here
typedef __darwin_uid_t uid_t;
^
5 errors generated.
make: *** [pointer-tools.o] Error 1
ERROR: compilation failed for package ārstanā
Any ideas for how to fix this? Seems like it might be related to this error
I think the problem is the type uuid_t is not defined at anywhere. So the declaration at line 662 in the file /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h will cause error for example.
In the first attempt, I tried to add one line into that unistd.h file: #include <sys/_types/_uuid_t.h> at line 83. But it doesnāt help.
Because I donāt want to go deeper to edit many system file, I add another line into unistd.h to manually define the type of uuid_t, based on the definition in _uuid_t.h . typedef __darwin_uuid_t uuid_t; at line 661, after ā#endifā.
Then it worked.
I am not sure if this is an error in the source code of MacOSX.10.15.sdk or not. But if you want to fix it in this way, please make sure you have the root permission when editing those files.
Iām getting weird behavior on Catalina when compiling any model that has an error. Instead of reporting the error, stan_model or stanc just returns with no error message, and no value returned. Thereafter no error messages nor warning messages of any sort are reported by any other command executed. Digging deeper I found that the FFI call within stanc fails, throwing an unknown C++ exception, and fails to properly restore stderr (which it had redirected to a file). Iāve filed this as issue #751 for standev/rstan.
Despite this, I can compile and run the 8schools example without problem, and likewise I can run prophet, which relies on RStan.
Yes, I carefully followed the instructions for installing RStan on MacOS Catalina using the āmacOS R toolchain installerā linked to on the page āInstalling RStan from source on a Macā, and this was fairly recently, with the last few weeks.
Has anyone else encountered this problem? Does anyone know of a reasonable work-around? Itās difficult to debug a Stan model if you canāt get back any error messages from the compiler.
When stanc returns nothing that just means there was a syntax error but Catalina is causing the error message to get lost. If you install rstan from source via CRAN, it should resolve itself.
Thanks, that seems to solve it. Itās puzzling, though, because I DID originally install RStan from source via CRAN, just a few weeks ago, and it was the same version (2.19.3).
@bgoodri sorry to bother you again but just curious if there was any other suggestion to try besides going in and editing the command line tools as suggested by @Tan_Phan? Mac pushed out a command line tools update a couple of days ago but that didnāt seem to solve eh problemā¦
I m experiencing the same issues ([1] "Error in sampler$call_sampler(args_list[[i]]) : ā[2] " c++ exception (unknown reason)ā error occurred during calling the sampler; sampling not done)
I ve been trying to follow the steps outlined here:
Downloaded toolchain - rmacoslib/r-macos-rtools
install.packages(c(āStanHeadersā, ārstanā), type = āsourceā)```
I have seen posts elsewhere about suggesting replacing Makevars - i m not sure what that is and whether it is necessary given the thread above.
I have Catalina and the newest R version and R-studio.
Edit: Iām on MacOS 10.15.5 and using R version 4.0.0 (2020-04-24)
@bgoodri@coatless I recently, accidentally updated RStan to 2.21 and Rcpp. I tried to uninstall it and reinstall Rcpp from drat (i.e., install.packages("Rcpp", repos = "https://rcppcore.github.io/drat")) but I now get
Warning in install.packages :
unable to access index for repository https://rcppcore.github.io/drat/bin/macosx/contrib/4.0:
cannot open URL 'https://rcppcore.github.io/drat/bin/macosx/contrib/4.0/PACKAGES'
If I just install the current Rcpp and then try to install RStan, I get the following error:
In file included from stan_fit.cpp:33:
In file included from ./stan/services/diagnose/diagnose.hpp:10:
In file included from ./stan/model/test_gradients.hpp:7:
In file included from ./stan/model/log_prob_grad.hpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat.hpp:51:
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat/fun/squared_distance.hpp:27:11: warning: unused type alias 'idx_t' [-Wunused-local-typedef]
using idx_t = typename index_type<matrix_v>::type;
^
/Library/Frameworks/R.framework/Versions/4.0/Resources/library/StanHeaders/include/stan/math/rev/mat/fun/squared_distance.hpp:64:11: warning: unused type alias 'idx_t' [-Wunused-local-typedef]
using idx_t = typename index_type<matrix_d>::type;
^
26 warnings generated.
ar -rs ../inst/lib//libStanServices.a stan_fit.o stan_fit_base.o
ar: creating archive ../inst/lib//libStanServices.a
installing to /Library/Frameworks/R.framework/Versions/4.0/Resources/library/00LOCK-rstan/00new/rstan/libs
** R
** inst
** byte-compile and prepare package for lazy loading
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/libs/Rcpp.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/libs/Rcpp.so, 6): Symbol not found: _EXTPTR_PTR
Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/libs/Rcpp.so
Expected in: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libR.dylib
in /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/libs/Rcpp.so
Calls: <Anonymous> ... asNamespace -> loadNamespace -> library.dynam -> dyn.load
Execution halted
ERROR: lazy loading failed for package ārstanā
* removing ā/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstanā
Warning in install.packages :
installation of package ārstanā had non-zero exit status
The downloaded source packages are in
ā/private/var/folders/zz/dvtr7nq911q1m2m0583x4tv40000gn/T/Rtmp7Oufnp/downloaded_packagesā