Errors while installing rstan on the posit cloud

Hi,

I’m new here need some helps. I’ve searched similar topics and found many suggestions, but could not translate solutions for the similar issues to mine with my knowledge. So sorry for bringing a similar issue.

I need to run “brms” package and using the posit cloud (paid account with 16G memory). I’m following an instruction here: How to install brms and dependecies • learnB4SS

as a first step, I installed rstan and run this code to see if it works:

example(stan_model, package = "rstan", run.dontrun = TRUE)

and got an error messages below.

using C++ compiler: ‘g++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0’using C++14g++: error: x86_64: No such file or directoryg++: error: unrecognized command line option ‘-arch’make: *** [/opt/R/4.3.1/lib/R/etc/Makeconf:200: file1803aa7f74c.o] Error 1

Here is information about my system:

  • Operating System: Mac Big Sur (11.7.8)
  • RStan Version: 2.21.0
  • Output of writeLines(readLines(file.path(Sys.getenv("HOME"), ".R/Makevars"))): CXX14FLAGS += -O3 -mtune=native -arch x86_64 -ftemplate-depth-256
  • Output of devtools::session_info("rstan")
    ─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────
    setting value
    version R version 4.3.1 (2023-06-16)
    os Ubuntu 20.04.6 LTS
    system x86_64, linux-gnu
    ui RStudio
    language (EN)
    collate C.UTF-8
    ctype C.UTF-8
    tz UTC
    date 2023-08-01
    rstudio 2023.03.1+446.pro1 Cherry Blossom (server)
    pandoc NA

─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────
package * version date (UTC) lib source
backports 1.4.1 2021-12-13 [1] RSPM (R 4.3.0)
BH 1.81.0-1 2023-01-22 [1] RSPM (R 4.3.0)
callr 3.7.3 2022-11-02 [1] RSPM (R 4.3.0)
checkmate 2.2.0 2023-04-27 [1] RSPM (R 4.3.0)
cli 3.6.1 2023-03-23 [1] RSPM (R 4.3.0)
colorspace 2.1-0 2023-01-23 [1] RSPM (R 4.3.0)
crayon 1.5.2 2022-09-29 [1] RSPM (R 4.3.0)
desc 1.4.2 2022-09-08 [1] RSPM (R 4.3.0)
fansi 1.0.4 2023-01-22 [1] RSPM (R 4.3.0)
farver 2.1.1 2022-07-06 [1] RSPM (R 4.3.0)
ggplot2 * 3.4.2 2023-04-03 [1] RSPM (R 4.3.0)
glue 1.6.2 2022-02-24 [1] RSPM (R 4.3.0)
gridExtra 2.3 2017-09-09 [1] RSPM (R 4.3.0)
gtable 0.3.3 2023-03-21 [1] RSPM (R 4.3.0)
inline 0.3.19 2021-05-31 [1] RSPM (R 4.3.0)
isoband 0.2.7 2022-12-20 [1] RSPM (R 4.3.0)
labeling 0.4.2 2020-10-20 [1] RSPM (R 4.3.0)
lattice 0.21-8 2023-04-05 [2] CRAN (R 4.3.1)
lifecycle 1.0.3 2022-10-07 [1] RSPM (R 4.3.0)
loo 2.6.0 2023-03-31 [1] RSPM (R 4.3.0)
magrittr 2.0.3 2022-03-30 [1] RSPM (R 4.3.0)
MASS 7.3-60 2023-05-04 [2] CRAN (R 4.3.1)
Matrix 1.5-4.1 2023-05-18 [2] CRAN (R 4.3.1)
matrixStats 1.0.0 2023-06-02 [1] RSPM (R 4.3.0)
mgcv 1.8-42 2023-03-02 [2] CRAN (R 4.3.1)
munsell 0.5.0 2018-06-12 [1] RSPM (R 4.3.0)
nlme 3.1-162 2023-01-31 [2] CRAN (R 4.3.1)
pillar 1.9.0 2023-03-22 [1] RSPM (R 4.3.0)
pkgbuild 1.4.2 2023-06-26 [1] RSPM (R 4.3.0)
pkgconfig 2.0.3 2019-09-22 [1] RSPM (R 4.3.0)
prettyunits 1.1.1 2020-01-24 [1] RSPM (R 4.3.0)
processx 3.8.2 2023-06-30 [1] RSPM (R 4.3.0)
ps 1.7.5 2023-04-18 [1] RSPM (R 4.3.0)
R6 2.5.1 2021-08-19 [1] RSPM (R 4.3.0)
RColorBrewer 1.1-3 2022-04-03 [1] RSPM (R 4.3.0)
Rcpp 1.0.11 2023-07-06 [1] RSPM (R 4.3.0)
RcppEigen 0.3.3.9.3 2022-11-05 [1] RSPM (R 4.3.0)
RcppParallel 5.1.7 2023-02-27 [1] RSPM (R 4.3.0)
rlang 1.1.1 2023-04-28 [1] RSPM (R 4.3.0)
rprojroot 2.0.3 2022-04-02 [1] RSPM (R 4.3.0)
rstan * 2.21.8 2023-01-17 [1] RSPM (R 4.3.0)
scales 1.2.1 2022-08-20 [1] RSPM (R 4.3.0)
StanHeaders * 2.26.27 2023-06-14 [1] RSPM (R 4.3.0)
tibble 3.2.1 2023-03-20 [1] RSPM (R 4.3.0)
utf8 1.2.3 2023-01-31 [1] RSPM (R 4.3.0)
vctrs 0.6.3 2023-06-14 [1] RSPM (R 4.3.0)
viridisLite 0.4.2 2023-05-02 [1] RSPM (R 4.3.0)
withr 2.5.0 2022-03-03 [1] RSPM (R 4.3.0)

[1] /cloud/lib/x86_64-pc-linux-gnu-library/4.3
[2] /opt/R/4.3.1/lib/R/library

Thanks so much for your help!

The issue is that you’ve followed the RStan instructions for MacOS, but Posit Cloud runs Linux.

In your Posit cloud session, run:

dotR <- file.path(Sys.getenv("HOME"), ".R")
if (!file.exists(dotR)) dir.create(dotR)
M <- file.path(dotR, "Makevars")
if (!file.exists(M)) file.create(M)
cat("\nCXX14FLAGS=-O3 -march=native -mtune=native -fPIC",
    "CXX14=g++",
    file = M, sep = "\n", append = FALSE)

Then try again

1 Like

Thanks so much for your help. I ran your code and now I see no error messages while running the example.

After this, I moved to run a brms model and got an error message (see below). If you have idea on what to do, please help me. Thanks!

Compiling Stan program…
Trying to compile a simple C file
Running /opt/R/4.3.1/lib/R/bin/R CMD SHLIB foo.c
using C compiler: ‘gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0’
gcc -I"/opt/R/4.3.1/lib/R/include" -DNDEBUG -I"/cloud/lib/x86_64-pc-linux-gnu-library/4.3/Rcpp/include/" -I"/cloud/lib/x86_64-pc-linux-gnu-library/4.3/RcppEigen/include/" -I"/cloud/lib/x86_64-pc-linux-gnu-library/4.3/RcppEigen/include/unsupported" -I"/cloud/lib/x86_64-pc-linux-gnu-library/4.3/BH/include" -I"/cloud/lib/x86_64-pc-linux-gnu-library/4.3/StanHeaders/include/src/" -I"/cloud/lib/x86_64-pc-linux-gnu-library/4.3/StanHeaders/include/" -I"/cloud/lib/x86_64-pc-linux-gnu-library/4.3/RcppParallel/include/" -I"/cloud/lib/x86_64-pc-linux-gnu-library/4.3/rstan/include" -DEIGEN_NO_DEBUG -DBOOST_DISABLE_ASSERTS -DBOOST_PENDING_INTEGER_LOG2_HPP -DSTAN_THREADS -DBOOST_NO_AUTO_PTR -include ‘/cloud/lib/x86_64-pc-linux-gnu-library/4.3/StanHeaders/include/stan/math/prim/fun/Eigen.hpp’ -D_REENTRANT -DRCPP_PARALLEL_USE_TBB=1 -I"/cloud/lib/x86_64-pc-linux-gnu-library/4.3/Rcpp/include" -I/usr/local/include -fpic -g -O2 -c foo.c -o foo.o
In file included from /cloud/lib/x86_64-pc-linux-gnu-library/4.3/RcppEigen/include/Eigen/Core:88,
from /cloud/lib/x86_64-pc-linux-gnu-library/4.3/RcppEigen/include/Eigen/Dense:1,
from /cloud/lib/x86_64-pc-linux-gnu-library/4.3/StanHeaders/include/stan/math/prim/fun/Eigen.hpp:22,
from :
/cloud/lib/x86_64-pc-linux-gnu-library/4.3/RcppEigen/include/Eigen/src/Core/util/Macros.h:628:1: error: unknown type name ‘namespace’
628 | namespace Eigen {
| ^~~~~~~~~
/cloud/lib/x86_64-pc-linux-gnu-library/4.3/RcppEigen/include/Eigen/src/Core/util/Macros.h:628:17: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘{’ token
628 | namespace Eigen {
| ^
In file included from /cloud/lib/x86_64-pc-linux-gnu-library/4.3/RcppEigen/include/Eigen/Dense:1,
from /cloud/lib/x86_64-pc-linux-gnu-library/4.3/StanHeaders/include/stan/math/prim/fun/Eigen.hpp:22,
from :
/cloud/lib/x86_64-pc-linux-gnu-library/4.3/RcppEigen/include/Eigen/Core:96:10: fatal error: complex: No such file or directory
96 | #include
| ^~~~~~~~~
compilation terminated.
make: *** [/opt/R/4.3.1/lib/R/etc/Makeconf:191: foo.o] Error 1