Error in unserialize(socklist[[n]]) : error reading from connection

I updated R to 4.3 and reinstalled all the packages I had previously. After updating, I am able to compile my stan model but when I try to fit the model, I get error:

Error in unserialize(socklist[[n]]) : error reading from connection

I have tried re-installing everything. The problem may involve needing to “Configure C++ Toolchain”. I tried installing the macrtools R package here (GitHub - coatless-mac/r-macos-rtools: Scripts to build an **unofficial** Rtools-esq installer for the macOS R toolchain) which “automatically installs and configures the R toolchain for compiled code on macOS” . The installation say successful, I reinstall rstan, but I still get the error.

Operating System: Mac 12.6.2 Apple M1 Max
Interface Version:
Compiler/Toolkit:

Looking forward to your topic!

1 Like

I have the same problem.

R version 4.3.0 (2023-04-21)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.4

1 Like

@Holly_Sullivan-Toole finally this worked for me: Installing Rstan - #2 by andrjohns

2 Likes

I just want to add that I just got the same error (Error in unserialize(socklist[[n]]) : error reading from connection), but a different solution than mentioned in this thread.

My Stan script compiled successfully. When computing the posterior with ‘rstan’ with >1 core, I get the Error in unserialize(socklist[[n]]) : error reading from connection, when computing the posterior with one core, the R session crashes (in both cases even before printing the message that the first chain was initialized).

For me, the issue was a bug in the Stan script which was not identified during compilation, and resolving this bug also resolved the error message and the posterior was computed successfully.