Dealing with Catalina

You are running this on localhost:8787?!? I, and others, have used the Docker image now for a number of days and I haven’t seen that error on Docker :( Can you send a MWE (incl. data) that I can try to run to see what happens?

I was hoping it could be that I was doing something wrong since I’m unfamiliar with much computer science. What do you mean by running it on localhost:8787 exactly?

@torkar I downloaded the Docker desktop app, ran the code you posted, I put localhost:8787 into Chrome an RStudio login appeared; I couldn’t log in, didn’t know what credentials it was after, I guessed it was the credentials I had made to download the Docker desktop app.

I’m clearly way out of my depth but I need to get RStan and its implementation through brms back in action.

@mansillo, in case there are more questions regarding Docker please start a new thread/question so we keep this separate from the issues in this forum.

Login using rstudio and the password you set when starting your docker image.

Has anyone tried g++ on Catalina, which you would have to download presumably?

Thanks, @Jonah. I am able to get cmdstanr to work correctly on stan models on Catalina after removing the .Renviron that sets the path to clang7, which I think was created as part of the @coatless instructions for rstan. I also removed the .Makevars file, so rstan is just using the apple clang compiler, but that may not have been needed for cmdstanr anyway. So this looks like at least a great interim option.

2 Likes

I upgraded to Catalina last week and rstan along with git was not working.

I ran xcode-select --install on the command line and it fixed the problem for me.

I got the solution from this link: https://apple.stackexchange.com/questions/254380/why-am-i-getting-an-invalid-active-developer-path-when-attempting-to-use-git-a

2 Likes

It might be interesting to see if PyStan on Catalina faces the same problems as RStan. One might think that it should, but given that I’ve seen other circumstances where PyStan worked but RStan failed, that’s far from guaranteed. If Catalina affects the two Stan interfaces differently, it may help narrow down the source of the problem.

A couple of notes:

  1. Using clang7 means having two copies of the libc++. The benefit of the second libc++ and clang7 compiler is access to OpenMP methods. Thus, when the clang7 compiler is removed from the PATH variable in .Renviron there is a loss of OpenMP compatibility. Again, mileage may vary for Stan, but this does go against the standard configuration. Perhaps two sets of installers are required?
  2. Deleting the ~/R/.Makevars file makes little sense as there must be variables set for the new location of the C header files in macOS Catalina.

What fixed what problem?

Running xcode-select --install on the command line fixed the error xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at:/Library/Developer/CommandLineTools/usr/bin/xcrun that I got when I tried to run the git command in the terminal.

This also fixed the issue I had when I tried compiling a model with rstan::stan. I don’t recall the exact error message from rstan::stan, but it seems to be related to the initial error above from git. After running xcode-select --install, compiling stan models works fine.

Ok, unless I’m misunderstanding, I think the issue on this thread is different. Stan files compile without an error but sampling fails with " c++ exception (unknown reason)”. If you don’t mind, then, try the minimal example from Ben above, or try sampling from stan program example above that has been throwing the error.

I believe I actually did have a sampling issue, and got the error c++ exception (unknown reason). So I was mistaken, sorry!

I ran the following line of code:

library(rstan)
library(brms)

output <- c(0.5237868884927709,0.9487179487179488,0.5494563370710159,0.46386348238482383,0.4458125179443009,0.9830952380952381,0.9685185185185186,0.5118241235888294,0.8824457593688363,0.5644325518178729,0.6317411924119242,0.4893159632500718,0.9416071428571429,0.9145833333333333,0.4509011685482273,0.7682445759368836,0.2748216106014271,0.7207063008130081,0.6109249005373036,0.9156547619047619,0.9011574074074074,0.6936423054070112,0.9012820512820513,0.8805895344886171,0.7585789295392954,0.6982066978384808,0.9988095238095238,0.9606481481481481,0.7225985343632402,0.9347140039447732,0.7936459395174992,0.7401422764227643,0.7547029449161232,0.9897619047619047,0.9571759259259259,0.734383046147752,1.0,0.8722222222222221,0.6707232384823848,0.6119692588491038,1.0,1.0,0.5487621311150723,0.8960552268244577,0.6401885830784912,0.7439871273712737,0.6910643533899349,0.9875,0.9847222222222223,0.5955040602099425,0.9396449704142013,0.5083588175331294,0.6947069783197831,0.5883210286698658,0.9872023809523809,0.9643518518518519)
categs<-as.factor(rep(c("FOO1","FOO2","FOO3","FOO4","FOO5","FOO6","FOO7","FOO8"),each=7));
blocks <- c(1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6,7)
df <- data.frame(y=output, algorithm=as.integer(categs), block_id=blocks)

post <- stan(model_code = make_stancode(y ~ 1 + (1 | algorithm), data = df),
             data = make_standata(y ~ 1 + (1 | algorithm), data = df), 
             verbose = TRUE)

When the sampling starts, I don’t get any errors:

CHECKING DATA AND PREPROCESSING FOR MODEL '4bd718ce37045da5116c1e4a2933dbfb' NOW.

COMPILING MODEL '4bd718ce37045da5116c1e4a2933dbfb' NOW.

STARTING SAMPLER FOR MODEL '4bd718ce37045da5116c1e4a2933dbfb' NOW.

SAMPLING FOR MODEL '4bd718ce37045da5116c1e4a2933dbfb' NOW (CHAIN 1).
Chain 1: 
Chain 1: Gradient evaluation took 1.9e-05 seconds
Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.19 seconds.
Chain 1: Adjust your expectations accordingly!
Chain 1: 
Chain 1: 
Chain 1: Iteration:    1 / 2000 [  0%]  (Warmup)
Chain 1: Iteration:  200 / 2000 [ 10%]  (Warmup)
Chain 1: Iteration:  400 / 2000 [ 20%]  (Warmup)
Chain 1: Iteration:  600 / 2000 [ 30%]  (Warmup)
Chain 1: Iteration:  800 / 2000 [ 40%]  (Warmup)
Chain 1: Iteration: 1000 / 2000 [ 50%]  (Warmup)
Chain 1: Iteration: 1001 / 2000 [ 50%]  (Sampling)
Chain 1: Iteration: 1200 / 2000 [ 60%]  (Sampling)
Chain 1: Iteration: 1400 / 2000 [ 70%]  (Sampling)
Chain 1: Iteration: 1600 / 2000 [ 80%]  (Sampling)
Chain 1: Iteration: 1800 / 2000 [ 90%]  (Sampling)
Chain 1: Iteration: 2000 / 2000 [100%]  (Sampling)
Chain 1: 
Chain 1:  Elapsed Time: 0.187013 seconds (Warm-up)
Chain 1:                0.105537 seconds (Sampling)
Chain 1:                0.29255 seconds (Total)
Chain 1: 

SAMPLING FOR MODEL '4bd718ce37045da5116c1e4a2933dbfb' NOW (CHAIN 2).
Chain 2: 
Chain 2: Gradient evaluation took 9e-06 seconds
Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.09 seconds.
Chain 2: Adjust your expectations accordingly!
Chain 2: 
Chain 2: 
Chain 2: Iteration:    1 / 2000 [  0%]  (Warmup)
Chain 2: Iteration:  200 / 2000 [ 10%]  (Warmup)
Chain 2: Iteration:  400 / 2000 [ 20%]  (Warmup)
Chain 2: Iteration:  600 / 2000 [ 30%]  (Warmup)
Chain 2: Iteration:  800 / 2000 [ 40%]  (Warmup)
Chain 2: Iteration: 1000 / 2000 [ 50%]  (Warmup)
Chain 2: Iteration: 1001 / 2000 [ 50%]  (Sampling)
Chain 2: Iteration: 1200 / 2000 [ 60%]  (Sampling)
Chain 2: Iteration: 1400 / 2000 [ 70%]  (Sampling)
Chain 2: Iteration: 1600 / 2000 [ 80%]  (Sampling)
Chain 2: Iteration: 1800 / 2000 [ 90%]  (Sampling)
Chain 2: Iteration: 2000 / 2000 [100%]  (Sampling)
Chain 2: 
Chain 2:  Elapsed Time: 0.19019 seconds (Warm-up)
Chain 2:                0.103686 seconds (Sampling)
Chain 2:                0.293876 seconds (Total)
Chain 2: 

SAMPLING FOR MODEL '4bd718ce37045da5116c1e4a2933dbfb' NOW (CHAIN 3).
Chain 3: 
Chain 3: Gradient evaluation took 1.1e-05 seconds
Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 0.11 seconds.
Chain 3: Adjust your expectations accordingly!
Chain 3: 
Chain 3: 
Chain 3: Iteration:    1 / 2000 [  0%]  (Warmup)
Chain 3: Iteration:  200 / 2000 [ 10%]  (Warmup)
Chain 3: Iteration:  400 / 2000 [ 20%]  (Warmup)
Chain 3: Iteration:  600 / 2000 [ 30%]  (Warmup)
Chain 3: Iteration:  800 / 2000 [ 40%]  (Warmup)
Chain 3: Iteration: 1000 / 2000 [ 50%]  (Warmup)
Chain 3: Iteration: 1001 / 2000 [ 50%]  (Sampling)
Chain 3: Iteration: 1200 / 2000 [ 60%]  (Sampling)
Chain 3: Iteration: 1400 / 2000 [ 70%]  (Sampling)
Chain 3: Iteration: 1600 / 2000 [ 80%]  (Sampling)
Chain 3: Iteration: 1800 / 2000 [ 90%]  (Sampling)
Chain 3: Iteration: 2000 / 2000 [100%]  (Sampling)
Chain 3: 
Chain 3:  Elapsed Time: 0.178866 seconds (Warm-up)
Chain 3:                0.107497 seconds (Sampling)
Chain 3:                0.286363 seconds (Total)
Chain 3: 

SAMPLING FOR MODEL '4bd718ce37045da5116c1e4a2933dbfb' NOW (CHAIN 4).
Chain 4: 
Chain 4: Gradient evaluation took 9e-06 seconds
Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 0.09 seconds.
Chain 4: Adjust your expectations accordingly!
Chain 4: 
Chain 4: 
Chain 4: Iteration:    1 / 2000 [  0%]  (Warmup)
Chain 4: Iteration:  200 / 2000 [ 10%]  (Warmup)
Chain 4: Iteration:  400 / 2000 [ 20%]  (Warmup)
Chain 4: Iteration:  600 / 2000 [ 30%]  (Warmup)
Chain 4: Iteration:  800 / 2000 [ 40%]  (Warmup)
Chain 4: Iteration: 1000 / 2000 [ 50%]  (Warmup)
Chain 4: Iteration: 1001 / 2000 [ 50%]  (Sampling)
Chain 4: Iteration: 1200 / 2000 [ 60%]  (Sampling)
Chain 4: Iteration: 1400 / 2000 [ 70%]  (Sampling)
Chain 4: Iteration: 1600 / 2000 [ 80%]  (Sampling)
Chain 4: Iteration: 1800 / 2000 [ 90%]  (Sampling)
Chain 4: Iteration: 2000 / 2000 [100%]  (Sampling)
Chain 4: 
Chain 4:  Elapsed Time: 0.177139 seconds (Warm-up)
Chain 4:                0.092964 seconds (Sampling)
Chain 4:                0.270103 seconds (Total)
Chain 4: 
1 Like

Try the Rcpp example: Dealing with Catalina

Ran it below and it looks fine to me.

R version 3.5.3 (2019-03-11) -- "Great Truth"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin15.6.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(readr) # or another package with compiled C++
> 
> 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()
Error in throw_exception() : this is an exception
> 
1 Like

I am out of my depth here, so this may be totally off the mark, but in the Fink discussion there was this post pointing out problems with the Apple Xcode headers in Catalina:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90835

So there is a bug in the Xcode header and perhaps that is what is happening here.

That’s great, the first working setup! Now we just need to understand how your configuration is different. Can you report what you have in your ~/.Renviron and ~/.R/Makevars files?

I also notice you are running an earlier version of R. I’m running the latest: R version 3.6.1 (2019-07-05) – “Action of the Toes”

Where are the ~/.Renviron and ~/.R/Makevars files located? I can’t find them on Spotlight.

A . file is hidden. You can see them in finder by holding down shift + command + .

same question w/r/t CmdStan - this discussion has me too spooked to upgrade

1 Like