I recently tried using the brms package in R (Windows 10) for the first time in a while, and I’ve found that it no longer works.
I’ve tried it in R 4.0.3 with brms 2.14.4 and rstan 2.21.2, and also in R 3.6.3 with brms 2.10.0 and rstan 2.21.2. In both cases it didn’t work.
I know that brms was working on this computer in October 2019 with brms 2.10.0 in R 3.6.1 (don’t know what version of rstan I had).
The code I tried was from the “Overview of the brms package” vignette and is shown below, together with the output when run in R 4.0.3.
library(brms)
data(kidney)
fit1 <- brm(formula = time | cens(censored) ~ age * sex + disease +
(1 + age|patient),
data = kidney, family = lognormal(),
prior = c(set_prior("normal(0,5)", class = "b"),
set_prior("cauchy(0,2)", class = "sd"),
set_prior("lkj(2)", class = "cor")),
warmup = 1000, iter = 2000, chains = 4,
control = list(adapt_delta = 0.95))
## Compiling Stan program...
## make cmd is
## make -f "c:/PROGRA~1/R/R-40~1.3/etc/x64/Makeconf" -f "c:/PROGRA~1/R/R-40~1.3/share/make/winshlib.mk" CXX='$(CXX14) $(CXX14STD)' CXXFLAGS='$(CXX14FLAGS)' CXXPICFLAGS='$(CXX14PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX14LDFLAGS)' SHLIB_LD='$(SHLIB_CXX14LD)' SHLIB="file4a1c79805383.dll" WIN=64 TCLBIN=64 OBJECTS="file4a1c79805383.o"
## make would use
## Error in compileCode(f, code, language = language, verbose = verbose) :
## In addition: Warning message:
## In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
## '-E' not found
## Error in sink(type = "output") : invalid connection
I’ve read through some similar threads here, and I’ve tried some of the suggestions:
- Use rstan 2.19.3 instead of the latest version.
- Load packages from a directory with no spaces in the name.
-
remotes::install_github("bgoodri/inline")
. - Reinstall RcppParallel.
None of those fixed the problem, so I reinstalled the latest rstan and inline, and went back to my usual package directory.
I have Rtools 40 in c:/rtools40 and I have Rtools 35 in c:/Rtools.
I’ve seen a lot of discussion about a “makevars” file but I don’t seem to have one and I don’t have a good understanding of what it is.
writeLines(readLines(file.path(Sys.getenv("HOME"), ".R/Makevars")))
## Error in file(con, "r") : cannot open the connection
## In addition: Warning message:
## In file(con, "r") :
## cannot open file 'C:\Users\seetom/.R/Makevars': No such file or directory
> devtools::session_info("rstan")
- Session info ---------------------------------------------------------------------------------------------
setting value
version R version 4.0.3 (2020-10-10)
os Windows 10 x64
system x86_64, mingw32
ui RTerm
language (EN)
collate English_Australia.1252
ctype English_Australia.1252
tz Australia/Sydney
date 2021-01-23
- Packages -------------------------------------------------------------------------------------------------
! package * version date lib source
assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.3)
backports 1.2.0 2020-11-02 [1] CRAN (R 4.0.3)
BH 1.72.0-3 2020-01-08 [1] CRAN (R 4.0.3)
brio 1.1.0 2020-08-31 [1] CRAN (R 4.0.3)
callr 3.5.1 2020-10-13 [1] CRAN (R 4.0.3)
checkmate 2.0.0 2020-02-06 [1] CRAN (R 4.0.3)
cli 2.2.0 2020-11-20 [1] CRAN (R 4.0.3)
colorspace 2.0-0 2020-11-11 [1] CRAN (R 4.0.3)
crayon 1.3.4 2017-09-16 [1] CRAN (R 4.0.3)
curl 4.3 2019-12-02 [1] CRAN (R 4.0.3)
desc 1.2.0 2018-05-01 [1] CRAN (R 4.0.3)
diffobj 0.3.2 2020-10-05 [1] CRAN (R 4.0.3)
digest 0.6.27 2020-10-24 [1] CRAN (R 4.0.3)
ellipsis 0.3.1 2020-05-15 [1] CRAN (R 4.0.3)
evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.3)
fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.3)
farver 2.0.3 2020-01-16 [1] CRAN (R 4.0.3)
ggplot2 3.3.2 2020-06-19 [1] CRAN (R 4.0.3)
glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.3)
gridExtra 2.3 2017-09-09 [1] CRAN (R 4.0.3)
gtable 0.3.0 2019-03-25 [1] CRAN (R 4.0.3)
inline 0.3.17 2020-12-01 [1] CRAN (R 4.0.3)
isoband 0.2.3 2020-12-01 [1] CRAN (R 4.0.3)
jsonlite 1.7.2 2020-12-09 [1] CRAN (R 4.0.3)
labeling 0.4.2 2020-10-20 [1] CRAN (R 4.0.3)
D lattice 0.20-41 2020-04-02 [1] CRAN (R 4.0.3)
lifecycle 0.2.0 2020-03-06 [1] CRAN (R 4.0.3)
loo 2.4.1 2020-12-09 [1] CRAN (R 4.0.3)
magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.0.3)
D MASS 7.3-53 2020-09-09 [1] CRAN (R 4.0.3)
Matrix 1.2-18 2019-11-27 [1] CRAN (R 4.0.3)
matrixStats 0.57.0 2020-09-25 [1] CRAN (R 4.0.3)
D mgcv 1.8-33 2020-08-27 [1] CRAN (R 4.0.3)
munsell 0.5.0 2018-06-12 [1] CRAN (R 4.0.3)
nlme 3.1-151 2020-12-10 [1] CRAN (R 4.0.3)
pillar 1.4.7 2020-11-20 [1] CRAN (R 4.0.3)
pkgbuild 1.2.0 2020-12-15 [1] CRAN (R 4.0.3)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.3)
pkgload 1.1.0 2020-05-29 [1] CRAN (R 4.0.3)
praise 1.0.0 2015-08-11 [1] CRAN (R 4.0.3)
prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.3)
processx 3.4.5 2020-11-30 [1] CRAN (R 4.0.3)
ps 1.5.0 2020-12-05 [1] CRAN (R 4.0.3)
R6 2.5.0 2020-10-28 [1] CRAN (R 4.0.3)
RColorBrewer 1.1-2 2014-12-07 [1] CRAN (R 4.0.3)
Rcpp * 1.0.5 2020-07-06 [1] CRAN (R 4.0.3)
RcppEigen 0.3.3.7.0 2019-11-16 [1] CRAN (R 4.0.3)
D RcppParallel 5.0.2 2020-06-24 [1] CRAN (R 4.0.3)
rematch2 2.1.2 2020-05-01 [1] CRAN (R 4.0.3)
rlang 0.4.9 2020-11-26 [1] CRAN (R 4.0.3)
rprojroot 2.0.2 2020-11-15 [1] CRAN (R 4.0.3)
rstan 2.21.2 2020-07-27 [1] CRAN (R 4.0.3)
rstudioapi 0.13 2020-11-12 [1] CRAN (R 4.0.3)
scales 1.1.1 2020-05-11 [1] CRAN (R 4.0.3)
StanHeaders 2.21.0-7 2020-12-17 [1] CRAN (R 4.0.3)
testthat 3.0.1 2020-12-17 [1] CRAN (R 4.0.3)
tibble 3.0.4 2020-10-12 [1] CRAN (R 4.0.3)
utf8 1.1.4 2018-05-24 [1] CRAN (R 4.0.3)
V8 3.4.0 2020-11-04 [1] CRAN (R 4.0.3)
vctrs 0.3.5 2020-11-17 [1] CRAN (R 4.0.3)
viridisLite 0.3.0 2018-02-01 [1] CRAN (R 4.0.3)
waldo 0.2.3 2020-11-09 [1] CRAN (R 4.0.3)
withr 2.3.0 2020-09-22 [1] CRAN (R 4.0.3)
[1] C:/Program Files/R/R-4.0.3/library
D -- DLL MD5 mismatch, broken installation.
I guess the “broken installation” in the output above is a sign that something is wrong.
In case it’s useful, example(stan_model, package = "rstan", run.dontrun = TRUE)
gave:
Loading required package: StanHeaders
Loading required package: ggplot2
rstan (Version 2.21.2, GitRev: 2e1f913d3ca3)
For execution on a local, multicore CPU with excess RAM we recommend calling
options(mc.cores = parallel::detectCores()).
To avoid recompilation of unchanged Stan programs, we recommend calling
rstan_options(auto_write = TRUE)
Do not specify '-march=native' in 'LOCAL_CPPFLAGS' or a Makevars file
stn_md> stancode <- 'data {real y_mean;} parameters {real y;} model {y ~ normal(y_mean,1);}'
stn_md> mod <- stan_model(model_code = stancode, verbose = TRUE)
TRANSLATING MODEL '73fc79f8b1915e8208c736914c86d1a1' FROM Stan CODE TO C++ CODE NOW.
successful in parsing the Stan model '73fc79f8b1915e8208c736914c86d1a1'.
Error in open.connection(con, open = mode) :
Timeout was reached: [github.com] Resolving timed out after 10000 milliseconds
In addition: Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
'-E' not found
COMPILING THE C++ CODE FOR MODEL '73fc79f8b1915e8208c736914c86d1a1' NOW.
OS: x86_64, mingw32; rstan: 2.21.2; Rcpp: 1.0.5; inline: 0.3.17
>> setting environment variables:
LOCAL_LIBS = "C:/Program Files/R/R-4.0.3/library/rstan/lib/x64/libStanServices.a" -L"C:/Program Files/R/R-4.0.3/library/StanHeaders/libs/x64" -lStanHeaders -L"C:/Program Files/R/R-4.0.3/library/RcppParallel/lib/x64" -ltbb
PKG_CPPFLAGS = -I"C:/Program Files/R/R-4.0.3/library/Rcpp/include/" -I"C:/Program Files/R/R-4.0.3/library/RcppEigen/include/" -I"C:/Program Files/R/R-4.0.3/library/RcppEigen/include/unsupported" -I"C:/Program Files/R/R-4.0.3/library/BH/include" -I"C:/Program Files/R/R-4.0.3/library/StanHeaders/include/src/" -I"C:/Program Files/R/R-4.0.3/library/StanHeaders/include/" -I"C:/Program Files/R/R-4.0.3/library/RcppParallel/include/" -I"C:/Program Files/R/R-4.0.3/library/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DBOOST_NO_AUTO_PTR -include "C:/Program Files/R/R-4.0.3/library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp" -std=c++1y
>> Program source :
[Lines removed]
make cmd is
make -f "c:/PROGRA~1/R/R-40~1.3/etc/x64/Makeconf" -f "c:/PROGRA~1/R/R-40~1.3/share/make/winshlib.mk" CXX='$(CXX14) $(CXX14STD)' CXXFLAGS='$(CXX14FLAGS)' CXXPICFLAGS='$(CXX14PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX14LDFLAGS)' SHLIB_LD='$(SHLIB_CXX14LD)' SHLIB="file4a1c7f433dfe.dll" WIN=64 TCLBIN=64 OBJECTS="file4a1c7f433dfe.o"
make would use
ERROR(s) during compilation: source code errors or compiler configuration errors!
Program source:
[Lines removed]
Compilation ERROR, function(s)/method(s) not created!
Error in compileCode(f, code, language = language, verbose = verbose) :
Thanks for any help you can give to solve this problem.