After installing brms, Rstan or brms will not load

Question 1: I have installed brms package and now my Rstan package will not load. Package brms also has the same issue.

> library(rstan)
Error: package or namespace load failed for ‘rstan’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/libs/Rcpp.so':
  dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/libs/Rcpp.so, 6): Symbol not found: _EXTPTR_PTR
  Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/libs/Rcpp.so
  Expected in: /Library/Frameworks/R.framework/Resources/lib/libR.dylib
 in /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/libs/Rcpp.so
In addition: Warning message:
package ‘rstan’ was built under R version 4.0.2 

> library(brms)
Loading required package: Rcpp
Error: package or namespace load failed for ‘Rcpp’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/libs/Rcpp.so':
  dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/libs/Rcpp.so, 6): Symbol not found: _EXTPTR_PTR
  Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/libs/Rcpp.so
  Expected in: /Library/Frameworks/R.framework/Resources/lib/libR.dylib
 in /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/libs/Rcpp.so
Error: package ‘Rcpp’ could not be loaded
In addition: Warning messages:
1: package ‘brms’ was built under R version 4.0.2 
2: package ‘Rcpp’ was built under R version 4.0.2 

Question 2: Is there a way to save current Rstudio settings so before installing a new package or updating packages that this problem is reversible?

Thank you!!

Please also provide the following information in addition to your question:

  • Operating System: Mac OS X Catalina 10.15.4
  • brms Version:2.13.3
1 Like

I would try reinstalling Rcpp via

install.packages("Rcpp")

and if that does not work

install.packages("Rcpp", type = "source")

Thank you for the quick reply! I tried installing Rcpp but that did not fix the issue. I used the type = source code and the error message is:

Loading required package: StanHeaders
Loading required package: ggplot2
Error: package or namespace load failed for ‘rstan’ in get(Info[i, 1], envir = env):
lazy-load database ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/R/Rcpp.rdb’ is corrupt
In addition: Warning messages:
1: package ‘rstan’ was built under R version 4.0.2
2: package ‘StanHeaders’ was built under R version 4.0.2
3: package ‘ggplot2’ was built under R version 4.0.2
4: In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1

I also uninstalled Rstan then reinstalled Rstan but this did not work either:

library(“rstan”)
Error: package or namespace load failed for ‘rstan’ in get(Info[i, 1], envir = env):
lazy-load database ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/R/Rcpp.rdb’ is corrupt
In addition: Warning messages:
1: In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1
2: In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1
3: In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1
4: In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1
5: In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1
6: In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1
7: In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1
8: package ‘rstan’ was built under R version 4.0.2
9: In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1

Another page that had a similar issue said this is resolved by restarting Rstudio but this did not work for me:

library(“rstan”)
Loading required package: StanHeaders
Loading required package: ggplot2
Need help getting started? Try the R Graphics Cookbok: https://r-graphics.org
Error: package or namespace load failed for ‘rstan’ in dyn.load(file, DLLpath = DLLpath, …):
unable to load shared object ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/libs/rstan.so’:
dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/libs/rstan.so, 6): Symbol not found: _EXTPTR_PTR
Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/libs/rstan.so
Expected in: /Library/Frameworks/R.framework/Resources/lib/libR.dylib
in /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rstan/libs/rstan.so
In addition: Warning messages:
1: package ‘rstan’ was built under R version 4.0.2
2: package ‘StanHeaders’ was built under R version 4.0.2
3: package ‘ggplot2’ was built under R version 4.0.2

Another post suggested updating R. This allowed Rstan to work with this message

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().

Is there a way to prevent this from happening in the future when installing new packages?

Not really, but it is best to install packages in clean R sessions without autoloading any old objects from an .RData file on disk. That way you avoid the “Rcpp.rdb is corrupt” messages.

Hi! I spent a long time today trying to figure this out. When nothing else worked, I updated my RStudio (which did not help either). However, after that, I update my R version and that fixed the issue for me.

1 Like

Same as @Sumeet_Sharma . I think this is a R 4.0.0 issue. The new versions of the packages worked fine for me once I upgraded from R 4.0.0 to R 4.0.2.