Dealing with Catalina IV

If you are trying to install the pkg from

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

What is packageVersion("BH")?

Thanks for the quick response!
Here’s the output:

packageVersion(“BH”)
[1] ‘1.72.0.3’

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.

So this is a bug in the Xcode command line tools? is there a previous version that works for sure? I’d rather not edit these if possible

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).