# Dealing with Catalina

**URL:** <https://discourse.mc-stan.org/t/dealing-with-catalina/11285>\
**Category:** Developers\
**Tags:** rstan\
**Created:** [October 7, 2019, 8:16pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina/11285 "2019-10-07T20:16:31Z")\
**Posts on this page:** 20\
**Page:** 10

<div class="post-metadata">

**Author:** ![wds15](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/wds15/32/908_2.png) [@wds15](https://discourse.mc-stan.org/u/wds15)\
**Post date:** [October 30, 2019, 6:36pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina/11285/182 "2019-10-30T18:36:52Z")

</div>

Does the just released 10.15.1 update make the situation any better?

This all sounds really horrible…and I wonder if other RCpp based projects suffer from the same problems?

(I have not yet dared to upgrade)

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [October 30, 2019, 6:43pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina/11285/183 "2019-10-30T18:43:57Z")

</div>

AFAICT, both `Rcpp::sourceCpp` and `inline::cxxfunction` will not work under Catalina (if exceptions are thrown) because the linker uses the system version of libc++.0.dylib rather than the one supplied by R or the one supplied by clang-7.

---

<div class="post-metadata">

**Author:** ![jroon](https://avatars.discourse-cdn.com/v4/letter/j/fbc32d/32.png) [@jroon](https://discourse.mc-stan.org/u/jroon)\
**Post date:** [October 30, 2019, 6:45pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina/11285/184 "2019-10-30T18:45:48Z")

</div>

Big list of Working/Not Working Apps here at least. Don’t know about other languages however

> **[Catalina Apps Working/Not working](https://forums.macrumors.com/threads/catalina-apps-working-not-working.2183923/)**
>
> Note: this is a wiki article
> 
> Working:
> 1Password 7.3.0
> 4D 17.2 Hot Fix 1
> Ableton Live 10 Lite
> Adapter
> AdGuard for Safari (2.0.4.552)
> AdGuard for Mac
> Adobe After Effects CC 2019 (16.1.1)
> Adobe Audition
> Adobe Illustrator 2019
> Adobe Lightroom Classic CC...

---

<div class="post-metadata">

**Author:** ![torkar](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/torkar/32/1355_2.png) [@torkar](https://discourse.mc-stan.org/u/torkar)\
**Post date:** [October 30, 2019, 7:35pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina/11285/185 "2019-10-30T19:35:12Z")

</div>

@wds15, 10.15.1 makes no difference. Same error occurs when sampling.

> Chain 3: Iteration: 1 / 2000 [0%] (Warmup)  
> [1] “Error in sampler$call\_sampler(args\_list[[i]]) : "  
> [2] " c++ exception (unknown reason)”  
> error occurred during calling the sampler; sampling not done

---

<div class="post-metadata">

**Author:** ![jonah](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jonah/32/200_2.png) [@jonah](https://discourse.mc-stan.org/u/jonah)\
**Post date:** [October 30, 2019, 9:11pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina/11285/186 "2019-10-30T21:11:14Z")

</div>

> [@bgoodri](#):
>
> AFAICT, both `Rcpp::sourceCpp` and `inline::cxxfunction` will not work under Catalina (if exceptions are thrown)

Yeah, although it’s curious that there are no open issues for either package (inline or Rcpp) that mention Catalina. I haven’t read the text of every issue but at least judging from all the issue titles it doesn’t seem like there are any. Any idea why not? If this isn’t just an RStan issue I would think this would be at the top of the priorities list for those packages (and they must be aware of it), but maybe I’m misunderstanding something relevant here.

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [October 30, 2019, 9:20pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina/11285/187 "2019-10-30T21:20:10Z")

</div>

I think it is just that not many people have upgraded to Catalina and even fewer are writing functions that branch on the exception type, that is getting mishandled by the combination of compilers and libraries being used. But it isn’t a Stan issue so someone that has Catalina and knows enough about compilation to be of help should post on R-SIG-Mac.

---

<div class="post-metadata">

**Author:** ![nicokist](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/nicokist/32/9155_2.png) [@nicokist](https://discourse.mc-stan.org/u/nicokist)\
**Post date:** [October 31, 2019, 10:27am UTC](https://discourse.mc-stan.org/t/dealing-with-catalina/11285/188 "2019-10-31T10:27:28Z")

</div>

I’m on Catalina and have not been experiencing this issue, the readr/sourceRCPP repex also shows the expected ‘this is an exception’ for me.

I wonder if it could be because I use the homebrew R package? I can’t think of anything else that’s different about my system.

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [October 31, 2019, 1:34pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina/11285/189 "2019-10-31T13:34:54Z")

</div>

Do you mean you use `g++` from homebrew?

---

<div class="post-metadata">

**Author:** ![nicokist](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/nicokist/32/9155_2.png) [@nicokist](https://discourse.mc-stan.org/u/nicokist)\
**Post date:** [October 31, 2019, 2:21pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina/11285/190 "2019-10-31T14:21:56Z")

</div>

No, I’m definitely using clang, version 11.0.0 (clang-1100.0.33.8).

```
/usr/local/Cellar/r/3.6.1_1/lib/R/bin/R CMD SHLIB -o 'sourceCpp_3.so' --preclean 'file60348a82cd.cpp'  
clang++ -arch x86_64 -ftemplate-depth-256 -I"/usr/local/Cellar/r/3.6.1_1/lib/R/include" -DNDEBUG -I"/usr/local/lib/R/3.6/site-library/Rcpp/include" -I"/private/var/folders/00/l8wh5r152f13_5xvrgh2slxw0000gn/T/RtmpZgCpyO/sourceCpp-x86_64-apple-darwin18.6.0-1.0.2" -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/include -fPIC -O3 -mtune=native -march=native -Wno-unused-variable -Wno-unused-function -c file60348a82cd.cpp -o file60348a82cd.o
clang++ -arch x86_64 -ftemplate-depth-256 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/opt/gettext/lib -L/usr/local/opt/readline/lib -L/usr/local/lib -L/usr/local/Cellar/r/3.6.1_1/lib/R/lib -L/usr/local/opt/gettext/lib -L/usr/local/opt/readline/lib -L/usr/local/lib -o sourceCpp_3.so file60348a82cd.o -L/usr/local/Cellar/r/3.6.1_1/lib/R/lib -lR -lintl -Wl,-framework -Wl,CoreFoundation
> 
> throw_exception()
Error in throw_exception() : this is an exception

```

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [October 31, 2019, 2:33pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina/11285/191 "2019-10-31T14:33:51Z")

</div>

But you are saying you got `clang++` from homebrew rather than from @coatless installer or from [https://cran.r-project.org/bin/macosx/tools](https://cran.r-project.org/bin/macosx/tools) ?

---

<div class="post-metadata">

**Author:** ![nicokist](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/nicokist/32/9155_2.png) [@nicokist](https://discourse.mc-stan.org/u/nicokist)\
**Post date:** [October 31, 2019, 2:44pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina/11285/192 "2019-10-31T14:44:24Z")

</div>

I’m pretty sure clang++ came from XCode. I don’t remember installing either the coatless software or the cran macosx tools you linked to.

```
BookTwo:bin $ which clang++
/usr/bin/clang++
BookTwo:bin $ clang++ --version
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin19.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

```

My R installation definitely came from homebrew (using brew install r), which is what I was trying to say above.

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [October 31, 2019, 2:51pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina/11285/193 "2019-10-31T14:51:37Z")

</div>

OK. It is known to be possible to avoid the mishandled exceptions if you avoid all of R’s clang stuff, but that is not a general enough workaround for us (or Rcpp / inline). In principle, everyone could just use Xcode but you lose out on the ability to use OpenMP and all the R packages compiled on CRAN that have Stan programs are still broken.

---

<div class="post-metadata">

**Author:** ![coatless](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/coatless/32/2052_2.png) [@coatless](https://discourse.mc-stan.org/u/coatless)\
**Post date:** [October 31, 2019, 11:46pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina/11285/194 "2019-10-31T23:46:58Z")

</div>

From reading @nicokist’s output, he’s using the `homebrew` compiler…

> [@nicokist](#):
>
> /usr/local/Cellar/r/3.6.1\_1/lib/R/bin/R CMD SHLIB -o ‘sourceCpp\_3.so’ --preclean ‘file60348a82cd.cpp’

So, moving totally away from _R_’s official binary works… Maybe this should be escalated over to Simon (macOS CRAN maintainer)

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [November 1, 2019, 1:06am UTC](https://discourse.mc-stan.org/t/dealing-with-catalina/11285/195 "2019-11-01T01:06:15Z")

</div>

If I had a Mac, I would. But I am not much use when I have to borrow someone else’s machine (that has Catalina) to respond to posts with test cases.

I can say that

```
Rcpp::sourceCpp(code = 
'
#include <Rcpp.h>
using namespace Rcpp; 

// [[Rcpp::export]]
int throw_exception() { 
  std::stringstream errmsg; errmsg << "this is an exception";
  throw std::domain_error(errmsg.str()); 
  return 0;
}
'
)

throw_exception()

```

works correctly (i.e. says “this is an exception”) if

- One uses `clang++` on Linux
- One uses homebrew’s R on a Mac with Catalina
- One uses Xcode’s `clang++` on a Mac with Catalina, provided no other C++ packages from CRAN have previously been loaded

And the problem has not much to do with Stan, except that we call `Rcpp::sourceCpp` and `inline::cxxfunction` and throw exceptions at runtime. But even packages like rstanarm wiith Stan programs that are compiled in advance on CRAN are affected.

---

<div class="post-metadata">

**Author:** ![janhannig](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/janhannig/32/6050_2.png) [@janhannig](https://discourse.mc-stan.org/u/janhannig)\
**Post date:** [November 7, 2019, 5:56pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina/11285/198 "2019-11-07T17:56:56Z")

</div>

Any updates?

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [November 7, 2019, 5:57pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina/11285/199 "2019-11-07T17:57:33Z")

</div>

Still broken

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [November 7, 2019, 11:49pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina/11285/200 "2019-11-07T23:49:51Z")

</div>

If you are using Catalina with the recommended `clang++` installer, try the advice in

> [@Dealing with Catalina II](https://discourse.mc-stan.org/t/dealing-with-catalina-ii/11802):
>
> If you have Catalina and clang++ installed from @coatless’s installer and rstan is not working, try the newest installer from

---

<div class="post-metadata">

**Author:** ![QuietSnooze](https://avatars.discourse-cdn.com/v4/letter/q/3e96dc/32.png) [@QuietSnooze](https://discourse.mc-stan.org/u/QuietSnooze)\
**Post date:** [November 9, 2019, 3:31pm UTC](https://discourse.mc-stan.org/t/dealing-with-catalina/11285/201 "2019-11-09T15:31:27Z")

</div>

Worked a treat - thank you! :)

---

<div class="post-metadata">

**Author:** ![Cathy\_Shi](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/cathy_shi/32/6425_2.png) [@Cathy\_Shi](https://discourse.mc-stan.org/u/Cathy_Shi)\
**Post date:** [November 13, 2019, 12:28am UTC](https://discourse.mc-stan.org/t/dealing-with-catalina/11285/202 "2019-11-13T00:28:31Z")

</div>

Thank you for that! I have installed them a while ago, so I just ran the code you provided. However, after running it, my stan file could check its gramma once before it didn’t work again. Is there anything I’m not doing correctly? Thanks!

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [November 13, 2019, 1:22am UTC](https://discourse.mc-stan.org/t/dealing-with-catalina/11285/203 "2019-11-13T01:22:25Z")

</div>

You may have to reinstall it from source at the moment with

```
install.packages("rstan", type = "source")

```

[Previous page](https://discourse.mc-stan.org/t/dealing-with-catalina/11285.md?page=9)

[Next page](https://discourse.mc-stan.org/t/dealing-with-catalina/11285.md?page=11)
