Dealing with Catalina III

That seemingly took care of it. There are no more prompts to install rtools. As far I can tell, everything seems to be functioning normally. Changing the Makevars file was evidently key. Thanks to all.

Works thanks!
install.packages(“rstan”, repos = “https://cloud.r-project.org/”, dependencies = TRUE)

Adding another datapoint to this. I have Catalina, freshly installed, in a VM to test rstan.

I took the following steps:

     - Requirements: R 3.6.3; Rstudio; XQuartz
       + After XQuartz: Must log out, and back in.
     - In terminal: xcode-select --install
     - Macos-Rtools
       + Download r-macos-rtools from https://github.com/rmacoslib/r-macos-rtools/releases/tag/v3.2.2
       + When downloaded, click "Downloads", go to "Open in Finder"; hold CTRL and right click on macos-rtools-3.2.2.pkg; click open. Install it.
     - RStan:
       + Open R (Not Rstudio? Was crashing in the VM)
       + Run the following: install.packages("Rcpp", repos = "https://rcppcore.github.io/drat")
	 * Say "Yes" when prompted to install from sources.
       + Run the following: install.packages("rstan", type = "source")

And changed literally nothing else. No makevars, nothing.

It worked fine. Ran the example in rstan::stan, and it seemed fine to me. Brms also worked fine.

The .R/Makevars contains the same as (Dealing with Catalina III). Note that I did not add that, nor modify it. I assume the R tools package did (?).

That is what is supposed to happen, but Catalina fails in different ways for different people so sometimes there are more steps to get rstan working.

Is there an organized list of ‘if it fails like ____, then try ____’ anywhere? We are going to introduce Stan to students on May 4, and we want them to install it a week prior to that using a document that tells them each step, and each step to take if something goes wrong.

Have the failures been due to ‘dirty’ Makevars files (e.g., having one Makevars pre-catalina, that does not work postupgrade)?

The plan is to hope that with CRAN switching back to an XCode based toolchain for R 4.0 in late April that there won’t have to be a Dealing with Catalina V thread.

I hope there is…I’ve given up on gettin rstan to work on my Mac and am running on ubuntu.

You shouldn’t give up. I think we have gotten 100% of Macs with Catalina to work eventually, but hopefully in a couple of weeks it won’t require extra effort.

3 Likes

minor thing – need to match the quote types in the above

Also, in the Coatless professor’s instructions…

curl -O http://r.research.att.com/libs/gfortran-4.8.2-darwin13.tar.bz2

apparently needs to be

curl -OL http://r.research.att.com/libs/gfortran-4.8.2-darwin13.tar.bz2

instead

Hi all,

I just bought a new mac laptop with Catalina (10.15.5). I am getting a weird error when running any stan model (in rstan or brms).

Error:

Error in unserialize(node$con) : error reading from connection
Calls: -> slaveLoop -> makeSOCKmaster
Error in unserialize(node$con) : error reading from connection
Calls: -> slaveLoop -> makeSOCKmaster
Error in unserialize(node$con) : error reading from connection
Calls: -> slaveLoop -> makeSOCKmaster
Error in unserialize(node$con) : error reading from connection
Calls: -> slaveLoop -> makeSOCKmaster
Execution halted
Execution halted
Execution halted
Execution halted
Error in makePSOCKcluster(names = spec, …) :
Cluster setup failed. 4 of 4 workers failed to connect.

R version info:

version
_
platform x86_64-apple-darwin17.0
arch x86_64
os darwin17.0
system x86_64, darwin17.0
status
major 4
minor 0.1
year 2020
month 06
day 06
svn rev 78648
language R
version.string R version 4.0.1 (2020-06-06)
nickname See Things Now

I can successfully load rstan & Rcpp libraries.

What should I do?

This is a known issue with RStudio and R4.0 at the moment, you can use the workaround in the below post to get things working again:

thank you!

System details: macOS 10.15.5, R 3.6.3, RStudio 1.3.959

I have installed rstan according to the instructions listed here based on my Catalina machine.

In a repeatable sequence, the Stan model attached does not run successfully (according to the attached R script) using 3 chains. Here are the error and warning messages:

Chain 1: Iteration:    1 / 10000 [  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

Chains 2 and 3 seem to run fine, but a final warning message is given stating “some chains had errors; consider specifying chains = 1 to debug”

Upon to setting chains = 1, the model runs perfectly the first time with no errors or warnings. Any subsequent run (simply executing the stan() function an additional time) yields the same error:

Chain 1: Iteration:    1 / 10000 [  0%]  (Warmup)
[1] "Error in sampler$call_sampler(args_list[[i]]) : " "  c++ exception (unknown reason)"                
error occurred during calling the sampler; sampling not done

I have removed and reinstalled all packages I understood as relevant (rstan, Rcpp, StanHeaders), and reinstalled the C++ toolchain. This model runs perfectly regardless of the number of chains on a different laptop running Ubuntu 20.04.

I appreciate any help!

Simple Linear Model in Stan.R (644 Bytes) Simple Linear Model.stan (172 Bytes)

Have to install rstan from source with the combination of Catalina and R 3.x .

Thanks, Ben. In all of my attempts to get Stan working I’ve only ever installed rstan from source according to the instructions I linked to in the original post. I have since uninstalled (remove.packages()) the StanHeaders and rstan packages, and reinstalled both from from source. This time I ran into an error where rstan could not be compiled because the libv8 engine could not be found. I installed v8 through brew and the rstan package installed. I now am seeing a new error message when fitting a model using stan() that reads:

sh: clang++ -mmacosx-version-min=10.13: command not found
The NEXT version of Stan will not be able to pre-process your Stan program.
Please open an issue at https://github.com/stan-dev/stanc3/issues
if you can share or at least describe your Stan program. This will help ensure that Stan
continues to work on your Stan programs in the future. Thank you!
This message can be avoided by wrapping your function call inside suppressMessages().

Which seems not affect the rstan() call because I can still successfully fit the model on a single chain. This final warning message is produced at the end of sampling:

Warning messages:
1: In system2(CXX, args = ARGS) : error in running command
2: In file.remove(c(unprocessed, processed)) :
cannot remove file ‘/var/folders/fn/5nszl9ps3px0hpxpz1jf8w2h0000gn/T//RtmpoOLK1C/file16ab621118ab0.stan’, reason ‘No such file or directory’

When increasing the number of chains to 3 the model is not fit, yielding an empty (Object with null pointer) stan() object and throwing the same final warning message as above.

EDIT: I am also using R 4.0.2 now

That appears to be several problems. Let’s start with what is the output of

rstan:::get_CXX()

?

> rstan:::get_CXX()
[1] "clang++ -mmacosx-version-min=10.13"

EDIT: I’ve found an open issue on the GitHub repository that relates to the clang++ message

sh: clang++ -mmacosx-version-min=10.13: command not found

Re: the more chronic multiple chains issue, it seems that this is only an issue when run in parallel on separate cores. When multiple chains are run in series on a single core there are no problems

2 Likes

This is where I’m stuck, I’ve done the following things and am getting this same error message. Help!

Steps to try to fix brms and Rcpp in Rstudio

  1. Uninstall Rstudio (Done)
  2. Update Rstudio (Done)
  3. Make sure Rstudio is running most up-to-date version (4.0.2) (Done)
  4. check if clang++ is installed (yes)
  5. Update Xcode if required for macOS Catalina 10.15.6 (Done)
  6. Open Xcode and install components it requires (Done)
    • current Version 11.6
  7. Restart computer (Don)

Compiling Stan program…
sh: clang++ -mmacosx-version-min=10.13: command not found

My Info:
macOS Catalina 10.15.6
R.Version: “R version 4.0.2 (2020-06-22)”
Rstudio Version: 1.3.1056

I was able to solve my problems and get a model running, here’s what I did:

Steps to try to fix brms and Rcpp in Rstudio

  1. Uninstall Rstudio
  2. Reinstall Rstudio
  3. Make sure Rstudio is running most up-to-date version
  4. check if clang++ is installed
  5. Update Xcode if required for macOS Catalina 10.15.6
  6. Open Xcode and install components it requires
  7. Restart computer
  8. Try to reinstall llvm with ‘brew reinstall llvm’
  9. Install from github the most recent version of brms
    • update all the packages that are out of date during brms install
    • error:
      clang-7: error: no such file or directory: ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/lib//libStanServices.a’
      make: *** [rstan.so] Error 1
      ERROR: compilation failed for package ‘rstan’
      • removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan’
      • restoring previous ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan’
        Error: Failed to install ‘brms’ from GitHub:
        (converted from warning) installation of package ‘rstan’ had non-zero exit status
    • try installing rstan from source
      -install r toolchain
    • remove rstan
    • restart R
    • install Rstan from source with install.packages("rstan", type = "source")
    • if rstan was successfully installed (D)
  10. load brms and try to run a simple model (it worked!!)