Error in Stan Code

I encountered an error using both the BRMS and RStan packages. Kindly let me know what is the problem here. Earlier, I had some issues after updating the R software. I think I fixed it, but now I am getting a new error message.
my code:
library(brms); library(wooldridge)
brm(affair~ educ + occup, data = affairs, chains = 4, iter = 1000 )
Compiling the C++ model
Start sampling
Error in Module(module, mustStart = TRUE) :
Failed to initialize module pointer: Error in FUN(X[[i]], …): no such symbol _rcpp_module_boot_stan_fit4model4ae278de7ecd_047e92e300c5ffe811bb310ae6552cf9_mod in package /var/folders/xh/_p6_xjm92bjg256ng5tgxbj80000gn/T//RtmpmpW3Ow/file4ae2305d8498.so

Sorry, I can’t reproduce this using R v4.0.0, OS X 10.15.4, brms 2.12.0.

 Family: gaussian 
  Links: mu = identity; sigma = identity 
Formula: affair ~ educ + occup 
   Data: affairs (Number of observations: 601) 
Samples: 4 chains, each with iter = 1000; warmup = 500; thin = 1;
         total post-warmup samples = 2000

Population-Level Effects: 
          Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
Intercept     0.22      0.12    -0.03     0.47 1.00     2220     1767
educ         -0.00      0.01    -0.02     0.02 1.00     1890     1598
occup         0.01      0.01    -0.01     0.03 1.00     1855     1540

Family Specific Parameters: 
      Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
sigma     0.43      0.01     0.41     0.46 1.00     1903     1620

Samples were drawn using sampling(NUTS). For each parameter, Bulk_ESS
and Tail_ESS are effective sample size measures, and Rhat is the potential
scale reduction factor on split chains (at convergence, Rhat = 1).

Thanks for the reply. I can reproduce these results in the Rstanarm package. But for some reason, I can’t do this in the brms or rstan package.

I used brms, have you tried the latest GitHub version:

remotes::install_github("paul-buerkner/brms")

I tried it, but it is the same.

What versions are you running (R, rstan, operating system)?

sessioninfo::session_info()
─ Session info ────────────────────────────────────────────────────────────────────────
setting value
version R version 4.0.0 (2020-04-24)
os macOS Catalina 10.15.4
system x86_64, darwin17.0
ui RStudio
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz America/New_York
date 2020-05-08

sessioninfo::package_info(c(“rstan”, “brms”))
! package * version date lib source
abind 1.4-5 2016-07-21 [1] CRAN (R 4.0.0)
askpass 1.1 2019-01-13 [1] CRAN (R 4.0.0)
assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.0)
backports 1.1.6 2020-04-05 [1] CRAN (R 4.0.0)
base64enc 0.1-3 2015-07-28 [1] CRAN (R 4.0.0)
bayesplot 1.7.1 2019-12-01 [1] CRAN (R 4.0.0)
BH 1.72.0-3 2020-01-08 [1] CRAN (R 4.0.0)
bridgesampling 1.0-0 2020-02-26 [1] CRAN (R 4.0.0)
brms * 2.12.9 2020-05-08 [1] Github (paul-buerkner/brms@6209a1e)
Brobdingnag 1.2-6 2018-08-13 [1] CRAN (R 4.0.0)
callr 3.4.3 2020-03-28 [1] CRAN (R 4.0.0)
checkmate 2.0.0 2020-02-06 [1] CRAN (R 4.0.0)
cli 2.0.2 2020-02-28 [1] CRAN (R 4.0.0)
coda 0.19-3 2019-07-05 [1] CRAN (R 4.0.0)
codetools 0.2-16 2018-12-24 [2] CRAN (R 4.0.0)
colorspace 1.4-1 2019-03-18 [1] CRAN (R 4.0.0)
colourpicker 1.0 2017-09-27 [1] CRAN (R 4.0.0)
crayon 1.3.4 2017-09-16 [1] CRAN (R 4.0.0)
crosstalk 1.1.0.1 2020-03-13 [1] CRAN (R 4.0.0)
curl 4.3 2019-12-02 [1] CRAN (R 4.0.0)
desc 1.2.0 2018-05-01 [1] CRAN (R 4.0.0)
digest 0.6.25 2020-02-23 [1] CRAN (R 4.0.0)
dplyr * 0.8.5 2020-03-07 [1] CRAN (R 4.0.0)
DT 0.13 2020-03-23 [1] CRAN (R 4.0.0)
dygraphs 1.1.1.6 2018-07-11 [1] CRAN (R 4.0.0)
ellipsis 0.3.0 2019-09-20 [1] CRAN (R 4.0.0)
evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.0)
fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.0)
farver 2.0.3 2020-01-16 [1] CRAN (R 4.0.0)
fastmap 1.0.1 2019-10-08 [1] CRAN (R 4.0.0)
future 1.17.0 2020-04-18 [1] CRAN (R 4.0.0)
ggplot2 * 3.3.0 2020-03-05 [1] CRAN (R 4.0.0)
ggridges 0.5.2 2020-01-12 [1] CRAN (R 4.0.0)
globals 0.12.5 2019-12-07 [1] CRAN (R 4.0.0)
glue 1.4.0 2020-04-03 [1] CRAN (R 4.0.0)
gridExtra 2.3 2017-09-09 [1] CRAN (R 4.0.0)
gtable 0.3.0 2019-03-25 [1] CRAN (R 4.0.0)
gtools 3.8.2 2020-03-31 [1] CRAN (R 4.0.0)
htmltools 0.4.0 2019-10-04 [1] CRAN (R 4.0.0)
htmlwidgets 1.5.1 2019-10-08 [1] CRAN (R 4.0.0)
httpuv 1.5.2 2019-09-11 [1] CRAN (R 4.0.0)
igraph 1.2.5 2020-03-19 [1] CRAN (R 4.0.0)
inline 0.3.15 2018-05-18 [1] CRAN (R 4.0.0)
isoband 0.2.1 2020-04-12 [1] CRAN (R 4.0.0)
jsonlite 1.6.1 2020-02-02 [1] CRAN (R 4.0.0)
labeling 0.3 2014-08-23 [1] CRAN (R 4.0.0)
later 1.0.0 2019-10-04 [1] CRAN (R 4.0.0)
lattice 0.20-41 2020-04-02 [1] CRAN (R 4.0.0)
lazyeval 0.2.2 2019-03-15 [1] CRAN (R 4.0.0)
lifecycle 0.2.0 2020-03-06 [1] CRAN (R 4.0.0)
listenv 0.8.0 2019-12-05 [1] CRAN (R 4.0.0)
loo 2.2.0 2019-12-19 [1] CRAN (R 4.0.0)
magrittr 1.5 2014-11-22 [1] CRAN (R 4.0.0)
markdown 1.1 2019-08-07 [1] CRAN (R 4.0.0)
MASS 7.3-51.6 2020-04-26 [1] CRAN (R 4.0.0)
Matrix 1.2-18 2019-11-27 [1] CRAN (R 4.0.0)
matrixStats 0.56.0 2020-03-13 [1] CRAN (R 4.0.0)
mgcv 1.8-31 2019-11-09 [1] CRAN (R 4.0.0)
mime 0.9 2020-02-04 [1] CRAN (R 4.0.0)
miniUI 0.1.1.1 2018-05-18 [1] CRAN (R 4.0.0)
munsell 0.5.0 2018-06-12 [1] CRAN (R 4.0.0)
mvtnorm 1.1-0 2020-02-24 [1] CRAN (R 4.0.0)
nleqslv 3.3.2 2018-05-17 [1] CRAN (R 4.0.0)
nlme 3.1-147 2020-04-13 [1] CRAN (R 4.0.0)
openssl 1.4.1 2019-07-18 [1] CRAN (R 4.0.0)
packrat 0.5.0 2018-11-14 [1] CRAN (R 4.0.0)
pillar 1.4.4 2020-05-05 [1] CRAN (R 4.0.0)
pkgbuild 1.0.8 2020-05-07 [1] CRAN (R 4.0.0)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.0)
pkgload 1.0.2 2018-10-29 [1] CRAN (R 4.0.0)
plogr 0.2.0 2018-03-25 [1] CRAN (R 4.0.0)
plyr 1.8.6 2020-03-03 [1] CRAN (R 4.0.0)
praise 1.0.0 2015-08-11 [1] CRAN (R 4.0.0)
prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.0)
processx 3.4.2 2020-02-09 [1] CRAN (R 4.0.0)
promises 1.1.0 2019-10-04 [1] CRAN (R 4.0.0)
ps 1.3.2 2020-02-13 [1] CRAN (R 4.0.0)
purrr * 0.3.4 2020-04-17 [1] CRAN (R 4.0.0)
R6 2.4.1 2019-11-12 [1] CRAN (R 4.0.0)
RColorBrewer 1.1-2 2014-12-07 [1] CRAN (R 4.0.0)
Rcpp * 1.0.4.6 2020-04-09 [1] CRAN (R 4.0.0)
RcppEigen 0.3.3.7.0 2019-11-16 [1] CRAN (R 4.0.0)
RcppParallel 5.0.0 2020-03-11 [1] CRAN (R 4.0.0)
reshape2 1.4.4 2020-04-09 [1] CRAN (R 4.0.0)
rlang 0.4.6 2020-05-02 [1] CRAN (R 4.0.0)
rprojroot 1.3-2 2018-01-03 [1] CRAN (R 4.0.0)
rsconnect 0.8.16 2019-12-13 [1] CRAN (R 4.0.0)
V rstan * 2.19.3 2020-05-08 [1] Github (stan-dev/rstan@5869a5e)
rstantools 2.0.0 2019-09-15 [1] CRAN (R 4.0.0)
rstudioapi 0.11 2020-02-07 [1] CRAN (R 4.0.0)
scales 1.1.0 2019-11-18 [1] CRAN (R 4.0.0)
shiny 1.4.0.2 2020-03-13 [1] CRAN (R 4.0.0)
shinyjs 1.1 2020-01-13 [1] CRAN (R 4.0.0)
shinystan 2.5.0 2018-05-01 [1] CRAN (R 4.0.0)
shinythemes 1.1.2 2018-11-06 [1] CRAN (R 4.0.0)
sourcetools 0.1.7 2018-04-25 [1] CRAN (R 4.0.0)
StanHeaders * 2.19.2 2020-02-11 [1] CRAN (R 4.0.0)
stringi 1.4.6 2020-02-17 [1] CRAN (R 4.0.0)
stringr * 1.4.0 2019-02-10 [1] CRAN (R 4.0.0)
sys 3.3 2019-08-21 [1] CRAN (R 4.0.0)
testthat 2.3.2 2020-03-02 [1] CRAN (R 4.0.0)
threejs 0.3.3 2020-01-21 [1] CRAN (R 4.0.0)
tibble * 3.0.1 2020-04-20 [1] CRAN (R 4.0.0)
tidyselect 1.0.0 2020-01-27 [1] CRAN (R 4.0.0)
utf8 1.1.4 2018-05-24 [1] CRAN (R 4.0.0)
V8 3.0.2 2020-03-14 [1] CRAN (R 4.0.0)
vctrs 0.2.4 2020-03-10 [1] CRAN (R 4.0.0)
viridisLite 0.3.0 2018-02-01 [1] CRAN (R 4.0.0)
withr 2.2.0 2020-04-20 [1] CRAN (R 4.0.0)
xfun 0.13 2020-04-13 [1] CRAN (R 4.0.0)
xtable 1.8-4 2019-04-21 [1] CRAN (R 4.0.0)
xts 0.12-0 2020-01-19 [1] CRAN (R 4.0.0)
yaml 2.2.1 2020-02-01 [1] CRAN (R 4.0.0)
V zoo 1.8-7 2020-05-02 [1] CRAN (R 4.0.0)

[1] /Users/karthy/Library/R/4.0/library
[2] /Library/Frameworks/R.framework/Versions/4.0/Resources/library

V ── Loaded and on-disk version mismatch.

Eh… this looks like the exact same setup I have. The only thing that’s different is I have:

rstan            2.19.3  2020-02-11 [1] CRAN (R 4.0.0)

and you have a star and a V on that line?

In ~/.R/Makevars I only have this:

FC = /usr/local/gfortran/bin/gfortran
FLIBS = -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm

and in ~/.Rprofile I have this:

## WORKAROUND: https://github.com/rstudio/rstudio/issues/6692
## Revert to 'sequential' setup of PSOCK cluster in RStudio Console on macOS and R 4.0.0
if (Sys.getenv("RSTUDIO") == "1" && !nzchar(Sys.getenv("RSTUDIO_TERM")) && 
    Sys.info()["sysname"] == "Darwin" && getRversion() == "4.0.0") {
  parallel:::setDefaultClusterOptions(setup_strategy = "sequential")
}

and I use the XCode's clang v11.0.3:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.59)
Target: x86_64-apple-darwin19.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin