Difficulty running brms on a Linux server

Short summary of the problem
Dear all,

Sorry to interrupt you, I am writing this letter to ask for your help.

I am running a Bayesian power analysis using the {brms} in a Server with Linux environment. But for some reason, when I run my Rmd script now (did not happen before) it tries to compile a foo.c file when running brms / Stan and it fails. But then, compiling the model with g++ works. So in short, I get the below error msg printed in the output from Rmd every time I try to run brms :

“/export/scratch1/home/xiongbin/soft/conda/envs/r-environment/lib/R/library/RcppEigen/include/Eigen/Core:96:10: fatal error: complex: No such file or directory
96 | #include
| ^~~~~~~~~
compilation terminated.
make: *** [/export/scratch1/home/xiongbin/soft/conda/envs/r-environment/lib/R/etc/Makeconf:169: foo.o] Error 1
Error in dyn.load(libLFile) :
unable to load shared object ‘/tmp/RtmpGy9tuO/file4d1b36c42348.so’:
/tmp/RtmpGy9tuO/file4d1b36c42348.so: failed to map segment from shared object: Operation not permitted
Error in sink(type = “output”) : invalid connection”

However, it should be noted that my script runs very well in a Windows system, just because I wanted to speed up my Bayesian power analysis, I used a Server.


I am sorry that I can only provide a piece of my code and I must modify the code to hide some information, as I have preregistered for my study but haven't run it yet. Please see following:

m1 <-
  brms::brm(data = MyData,
            family = binomial,
            choice|trials(1) ~ 0 + condition + (0 + condition | subjID),
            prior = c(prior(normal(2.5, 0.3), 
                            class = b, coef = condition1),
                      prior(normal(2.5, 0.3), 
                            class = b, coef = condition2),
                      prior(normal(2.5, 0.3),
                            class = b, coef = condition3),
                      prior(normal(2.5, 0.3),
                            class = b, coef = condition4),
                      prior(normal(0, 0.6), class = sd),
                      prior(lkj(3), class = cor)),
            iter = 2000,
            warmup = 1000,
            chains = 4,
            cores = 4,
            seed = 9513, 
            sample_prior = "only")

If possible, add also code to simulate data or attach a (subset of) the dataset you work with.

Please also provide the following information in addition to your question: 
* Operating System: Linux version 3.10.0-1127.19.1.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-39)
* brms Version: brms version 2.14.4

Looking forward to your topic!


I am guessing this is the same issue that was posted on the brms issue tracker where you noted that the gcc version on the system is 4.8.5.

This is below the minimum required gcc/g++ for rstan/stan. The g++ compiler needs to be upgraded to at least 4.9.3 but I would suggest going to something newer.

Hi Rok,

Yes, the same issue, sorry for this. I now know how to solve the problem. Many thanks,

Have a nice day!

1 Like

Hi Rok,

I updated the gcc version and now it’s 5.4.0. But very frustrating, the brms still CANNOT run in the Server with a Linux system. I got the following error message:

gcc version5.4.0;gcc_impl_linux-64 version 9.3.0
gcc_linux-64 version=9.3.0; gxx_linux-64 version=9.3.0;
/export/scratch1/home/xiongbin/soft/conda/envs/r-environment/bin/…/lib/gcc/x86_64-conda-linux-gnu/9.3.0/…/…/…/…/x86_64-conda-linux-gnu/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status
make: *** [/export/scratch1/home/xiongbin/soft/conda/envs/r-environment/lib/R/share/make/shlib.mk:6: foo.so] Error 1
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! In file included from /export/scratch1/home/xiongbin/soft/conda/envs/r-environment/lib/R/library/RcppEigen/include/Eigen/Core:392

Do you perhaps know how to solve it? Also, it seems the {brms} often crushed in a Linux system for reasons unkown.

Have a nice evening,


Just double checking, what does

g++ --version return

Hi Rok,

Sorry for my delayed reply. The instruction ‘g++ --version’ returns the following:

g++ --version
g++ (GCC) 5.4.0
Copyright © 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO

Do you need me to provide my R script and corresponding dataset?

If I remember correctly there was some weirdness with conda not updating all the gcc libraries correctly (back in 2017,2018). Not sure if that’s the issue here.

1 Like

Hi Ara,

Thanks for your reply, I uploaded a screenshot of my Conda list, I am wondering whether all the gcc libraries are updated?


Looking forward to your reply

Have a nice day

Disclaimer: I do not have experience with Conda as I usually work without these environments so this is more of a stab in the dark.

As it looks, the Conda environment is setup for g++ 9.3.0. Can you try installing that version of g++?

1 Like

Hi Rok,

I will try that now.

Many thanks.


Did you manage to find a solution? I’ve got similar problems with compiling rstan models using gcc/g++ 9.3.0, with -lgcc_s not being found. I’ve tried installing gcclib which has made no difference. Any pointers welcome!


Hi rittman,

Unfortunately, no, I still did not figure out where is the problem. But I noticed that the brms worked in Linux system one year ago, with some previous version packages. So I am thinking may be I should re-install some previous version packages and see whether it works. But very annoying

Thanks for the reply. I’ll also let you know if I find an answer. I agree, it’s very frustrating.