Dealing with Catalina III

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

@lakemonster Sorry for the hassle but glad it’s working now!

Hi everyone!
I am new to RStan. I am trying to run a model with RStan but all in vain. It looks like RStan is not properly installed or I am missing any part of it. Could someone please guide me how to uninstall and reinstall RStan on my Mac?
I am using macOS Catalina version 10.15.7

Thank you!

What version of R?

Its 1.3.1093

I think that is your version of RStudio (which also could stand to be upgraded). What is the result when you execute

R.version

in R?

I am sorry, 1.3.1093 is the version of R studio. the R version is 4.0.3 as shown by the command R.version.