I am trying to install the R package brms
on my Ubuntu 22.04 LTS computer. My R version is 4.2.2 and I am using RStudio RStudio 2022.07.2 "Spotted Wakerobin".
rstan
is installed and I have successfully verified the installation. My stan version is 2.21.0.
When I try installing brms
in RStudio this is the output:
> install.packages("brms")
Installing package into ‘/home/iplank/R/x86_64-pc-linux-gnu-library/4.2’
(as ‘lib’ is unspecified)
also installing the dependencies ‘bayesplot’, ‘shinystan’, ‘bridgesampling’, ‘nleqslv’
trying URL 'https://cloud.r-project.org/src/contrib/bayesplot_1.10.0.tar.gz'
Content type 'application/x-gzip' length 4993447 bytes (4.8 MB)
==================================================
downloaded 4.8 MB
trying URL 'https://cloud.r-project.org/src/contrib/shinystan_2.6.0.tar.gz'
Content type 'application/x-gzip' length 2399890 bytes (2.3 MB)
==================================================
downloaded 2.3 MB
trying URL 'https://cloud.r-project.org/src/contrib/bridgesampling_1.1-2.tar.gz'
Content type 'application/x-gzip' length 1679600 bytes (1.6 MB)
==================================================
downloaded 1.6 MB
trying URL 'https://cloud.r-project.org/src/contrib/nleqslv_3.3.3.tar.gz'
Content type 'application/x-gzip' length 84686 bytes (82 KB)
==================================================
downloaded 82 KB
trying URL 'https://cloud.r-project.org/src/contrib/brms_2.18.0.tar.gz'
Content type 'application/x-gzip' length 4486548 bytes (4.3 MB)
==================================================
downloaded 4.3 MB
* installing *source* package ‘bayesplot’ ...
** package ‘bayesplot’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error in element_line(linewidth = 0.3) :
unused argument (linewidth = 0.3)
Error: unable to load R code in package ‘bayesplot’
Execution halted
ERROR: lazy loading failed for package ‘bayesplot’
* removing ‘/home/iplank/R/x86_64-pc-linux-gnu-library/4.2/bayesplot’
Warning in install.packages :
installation of package ‘bayesplot’ had non-zero exit status
* installing *source* package ‘bridgesampling’ ...
** package ‘bridgesampling’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (bridgesampling)
* installing *source* package ‘nleqslv’ ...
** package ‘nleqslv’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gcc -I"/usr/share/R/include" -DNDEBUG -I"/usr/lib/R/site-library/Rcpp/include/" -I"/usr/lib/R/site-library/RcppEigen/include/" -I"/usr/lib/R/site-library/RcppEigen/include/unsupported" -I"/usr/lib/R/site-library/BH/include" -I"/usr/lib/R/site-library/StanHeaders/include/src/" -I"/usr/lib/R/site-library/StanHeaders/include/" -I"/usr/lib/R/site-library/RcppParallel/include/" -I"/home/iplank/R/x86_64-pc-linux-gnu-library/4.2/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DBOOST_NO_AUTO_PTR -include '/usr/lib/R/site-library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp' -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1 -fpic -g -O2 -ffile-prefix-map=/build/r-base-Faorqz/r-base-4.2.2.20221110=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c init.c -o init.o
In file included from /usr/lib/R/site-library/RcppEigen/include/Eigen/Core:88,
from /usr/lib/R/site-library/RcppEigen/include/Eigen/Dense:1,
from /usr/lib/R/site-library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13,
from <command-line>:
/usr/lib/R/site-library/RcppEigen/include/Eigen/src/Core/util/Macros.h:628:1: error: unknown type name ‘namespace’
628 | namespace Eigen {
| ^~~~~~~~~
/usr/lib/R/site-library/RcppEigen/include/Eigen/src/Core/util/Macros.h:628:17: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
628 | namespace Eigen {
| ^
In file included from /usr/lib/R/site-library/RcppEigen/include/Eigen/Dense:1,
from /usr/lib/R/site-library/StanHeaders/include/stan/math/prim/mat/fun/Eigen.hpp:13,
from <command-line>:
/usr/lib/R/site-library/RcppEigen/include/Eigen/Core:96:10: fatal error: complex: No such file or directory
96 | #include <complex>
| ^~~~~~~~~
compilation terminated.
make: *** [/usr/lib/R/etc/Makeconf:169: init.o] Error 1
ERROR: compilation failed for package ‘nleqslv’
* removing ‘/home/iplank/R/x86_64-pc-linux-gnu-library/4.2/nleqslv’
Warning in install.packages :
installation of package ‘nleqslv’ had non-zero exit status
ERROR: dependency ‘bayesplot’ is not available for package ‘shinystan’
* removing ‘/home/iplank/R/x86_64-pc-linux-gnu-library/4.2/shinystan’
Warning in install.packages :
installation of package ‘shinystan’ had non-zero exit status
ERROR: dependencies ‘bayesplot’, ‘shinystan’, ‘nleqslv’ are not available for package ‘brms’
* removing ‘/home/iplank/R/x86_64-pc-linux-gnu-library/4.2/brms’
Warning in install.packages :
installation of package ‘brms’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpS56F1Q/downloaded_packages’
There seems to be a problem when installing bayesplot
but I’m not sure how to solve it.
Does anyone have any suggestions?
2
Answers
Just in case someon encounters the same problem:
I installed
devtools
to be able to installbayesplot
directly from github using:This only worked for me after installing all the packages that throw compilation errors in R directly and not in RStudio.
After
bayesplot
was installed, I was able to installbrms
.I encountered the same problem and installing the development version no longer works. Now, you need to specify version
1.9.0
to installbayesplot
:Information on this bug can be found at the following github issue:
https://github.com/stan-dev/bayesplot/issues/297