Brms installation problems on ubuntu 22.04.1 LTS

Dear brms users and creators,

I would be very thankful if you could point me to any potentially helpful thoughts about the following:

Short summary of the problem:

I have tried to install brms on my Ubuntu machine. It was quite inconvenient (“dependency hell”, quite some manual patching of this and that), and in the end after a restart of RStudio the installation of brms finished without complaints.

As far as I can tell, rstan has also been successfully installed. I can run this test script without problems.

However, when I run a fairly simple model,

Code (happens both in RStudio & running script from shell via Rscript):

mdl0 <- brm(y ~ a + b + c, 
           data = Data,
           family = Beta(link = "logit", link_phi = "log"),
           chains = 1,
           warmup = 1000,
           cores = 1,
           iter = 2000)

Results in the following output:

Compiling Stan program...
Start sampling

SAMPLING FOR MODEL '6c9a0d5a4fd701d932ade703e8e7bfc2' NOW (CHAIN 1).
Chain 1: 
Chain 1: Gradient evaluation took 0.002253 seconds
Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 22.53 seconds.
Chain 1: Adjust your expectations accordingly!
Chain 1: 
Chain 1: 
double free or corruption (out)

If I change the family to gaussian, i.e. run this model:

mdlGauss <- brm(y ~ a + b + c, 
            data = Data,
            family = gaussian(),
            chains = 1,
            warmup = 1000,
            cores = 1,
            iter = 2000)

It finishes without problems.

When I run the basic demo script from the brms github page, i.e.:

fit1 <- brm(count ~ zAge + zBase * Trt + (1|patient),
            data = epilepsy, family = poisson())

I get the following output (there are a few more lines, but I cannot copy them as “R encountered a fatal error. The session was terminated”).

Compiling Stan program...
Start sampling

SAMPLING FOR MODEL '58b43e7972874ac46e71dffc8a4f2faf' NOW (CHAIN 1).
Chain 1: 
Chain 1: Gradient evaluation took 3.8e-05 seconds
Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.38 seconds.
Chain 1: Adjust your expectations accordingly!
Chain 1: 
Chain 1: 
Chain 1: Iteration:    1 / 2000 [  0%]  (Warmup)
Chain 1: Iteration:  200 / 2000 [ 10%]  (Warmup)
Chain 1: Iteration:  400 / 2000 [ 20%]  (Warmup)
Chain 1: Iteration:  600 / 2000 [ 30%]  (Warmup)
Chain 1: Iteration:  800 / 2000 [ 40%]  (Warmup)
Chain 1: Iteration: 1000 / 2000 [ 50%]  (Warmup)
Chain 1: Iteration: 1001 / 2000 [ 50%]  (Sampling)
Chain 1: Iteration: 1200 / 2000 [ 60%]  (Sampling)
Chain 1: Iteration: 1400 / 2000 [ 70%]  (Sampling)
Chain 1: Iteration: 1600 / 2000 [ 80%]  (Sampling)
Chain 1: Iteration: 1800 / 2000 [ 90%]  (Sampling)
Chain 1: Iteration: 2000 / 2000 [100%]  (Sampling)
Chain 1: 
Chain 1:  Elapsed Time: 1.53635 seconds (Warm-up)
Chain 1:                1.18233 seconds (Sampling)
Chain 1:                2.71868 seconds (Total)
Chain 1: 

SAMPLING FOR MODEL '58b43e7972874ac46e71dffc8a4f2faf' NOW (CHAIN 2).
Chain 2: 
Chain 2: Gradient evaluation took 2.1e-05 seconds
Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.21 seconds.
Chain 2: Adjust your expectations accordingly!
Chain 2: 
Chain 2: 
Chain 2: Iteration:    1 / 2000 [  0%]  (Warmup)
Chain 2: Iteration:  200 / 2000 [ 10%]  (Warmup)
Chain 2: Iteration:  400 / 2000 [ 20%]  (Warmup)
Chain 2: Iteration:  600 / 2000 [ 30%]  (Warmup)
Chain 2: Iteration:  800 / 2000 [ 40%]  (Warmup)
Chain 2: Iteration: 1000 / 2000 [ 50%]  (Warmup)
Chain 2: Iteration: 1001 / 2000 [ 50%]  (Sampling)
Chain 2: Iteration: 1200 / 2000 [ 60%]  (Sampling)
Chain 2: Iteration: 1400 / 2000 [ 70%]  (Sampling)
Chain 2: Iteration: 1600 / 2000 [ 80%]  (Sampling)
Chain 2: Iteration: 1800 / 2000 [ 90%]  (Sampling)
Chain 2: Iteration: 2000 / 2000 [100%]  (Sampling)
Chain 2: 
Chain 2:  Elapsed Time: 1.66488 seconds (Warm-up)
Chain 2:                1.2286 seconds (Sampling)
Chain 2:                2.89348 seconds (Total)
Chain 2: 

SAMPLING FOR MODEL '58b43e7972874ac46e71dffc8a4f2faf' NOW (CHAIN 3).
Chain 3: 
Chain 3: Gradient evaluation took 2.1e-05 seconds
Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 0.21 seconds.
Chain 3: Adjust your expectations accordingly!
Chain 3: 
Chain 3: 
Chain 3: Iteration:    1 / 2000 [  0%]  (Warmup)
[22530:22530:20230117,112805.807411:ERROR process_memory_range.cc:86] read out of range
[22530:22530:20230117,112805.807441:ERROR elf_image_reader.cc:558] missing nul-terminator
[22530:22530:20230117,112805.807465:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808230:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808245:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808260:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808275:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808290:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808305:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808430:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808445:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808585:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808601:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808618:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808633:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808649:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808666:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808681:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808697:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808712:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808727:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808742:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808758:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808773:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808789:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808805:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808820:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808837:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808853:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808869:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808885:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808899:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808915:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808930:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808945:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808961:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808976:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.808992:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.809007:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.809023:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.809039:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.809052:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.809068:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.809082:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.809099:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.809115:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.809129:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.809145:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.809160:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:22530:20230117,112805.809175:ERROR elf_dynamic_array_reader.h:61] tag not found
[22530:225

[...]

At the very end of this output, it reports (copied manually, as R session already dead):
22530:22531:20230117,112805.830005:ERROR directory_reader_posix.cc:42] opendir: No such file or directory (2)

Problematic environment details where these bugs occur:

  • Operating System: ubuntu 22.04.1 LTS
  • R: 4.2.2
  • RStudio: 2022.12.0 Build 353
  • brms Version: 2.18.0

All of the above scripts successfully run on a macbook with the following environment:

  • Operating System: Mac OS Ventura 13.0.1
  • R: 4.2.2
  • RStudio: 2022.12.0+353
  • brms Version: 2.18.0

Any help to diagnose what is going on and tips for how I could fix this would be very welcome!
Many many thanks,
Christoph

Could you try with the most recent development version of brms? I feel like I have seen something similar recently so there might be fix on github already.

Also, what problems did you have when installing? I don’t think I ever had problems on linux before.

Thank you very much for your post!

I have tried the following to update to the current developmental version:

if (!requireNamespace("remotes")) {
  install.packages("remotes")
}
remotes::install_github("paul-buerkner/brms")

Which has worked without issues, so I assume the update to the developmental version worked – the error messages remain the same for all cases.

The problems I had while installing were that it got stuck at pretty much each step along the way and complained about something missing, unfortunately I do not precisely remember what these things were. I do remember that at some point I installed liblapack-dev and libopenblas-dev, which made something along the way work, and I do remember that before the brms installation stopped complaining, I shut down Rstudio and reopened it (I have restarted the machine as well ;).

Something I have found to be slightly weird: When I try to install the package “devtools”, I get the following errors:

ERROR: configuration failed for package ‘xml2’
* removing ‘/home/chrisd/R/x86_64-pc-linux-gnu-library/4.2/xml2’
Warning in install.packages :
  installation of package ‘xml2’ had non-zero exit status
ERROR: dependency ‘textshaping’ is not available for package ‘ragg’
* removing ‘/home/chrisd/R/x86_64-pc-linux-gnu-library/4.2/ragg’
Warning in install.packages :
  installation of package ‘ragg’ had non-zero exit status
ERROR: dependency ‘xml2’ is not available for package ‘roxygen2’
* removing ‘/home/chrisd/R/x86_64-pc-linux-gnu-library/4.2/roxygen2’
Warning in install.packages :
  installation of package ‘roxygen2’ had non-zero exit status
ERROR: dependency ‘xml2’ is not available for package ‘rversions’
* removing ‘/home/chrisd/R/x86_64-pc-linux-gnu-library/4.2/rversions’
Warning in install.packages :
  installation of package ‘rversions’ had non-zero exit status
ERROR: dependency ‘xml2’ is not available for package ‘urlchecker’
* removing ‘/home/chrisd/R/x86_64-pc-linux-gnu-library/4.2/urlchecker’
Warning in install.packages :
  installation of package ‘urlchecker’ had non-zero exit status
ERROR: dependencies ‘ragg’, ‘xml2’ are not available for package ‘pkgdown’
* removing ‘/home/chrisd/R/x86_64-pc-linux-gnu-library/4.2/pkgdown’
Warning in install.packages :
  installation of package ‘pkgdown’ had non-zero exit status
ERROR: dependencies ‘pkgdown’, ‘roxygen2’, ‘rversions’, ‘urlchecker’ are not available for package ‘devtools’
* removing ‘/home/chrisd/R/x86_64-pc-linux-gnu-library/4.2/devtools’
Warning in install.packages :
  installation of package ‘devtools’ had non-zero exit status

Wondering: Could it be something like the whole combination of R 4.2.2 and Ubuntu 22.04 isn’t working?

Any further tips would be much appreciated!

Your linux is missing some libraries. For example, you need r-cran-ragg , r-cran-xml2.

When you open the Terminal, you can type:

sudo apt install r-cran-ragg r-cran-xml2

You may need more. Go thru your error messages and google “ubuntu xxx” where xxx is the package failed to install. Good luck

Ok great, thanks, at least that solves the problem with installing devtools, which now works.
The rest however seems to be unchanged (R crashing for poisson example model, and it returns “double free or corruption (out)” for beta family on my own data).

I don’t have anything more useful than suggesting you to remove and reinstall R.

Thanks again for that tip!
I finally found some time and removed everything related to R on this machine, reinstalled everything, and now it finally works.

Unfortunately, I am not sure what exactly I did differently this time – feels like I followed the same steps specified here, here and by @scholz (i.e. installing r-cran-ragg and r-cran-xml2). Maybe having some libraries installed already that I had to patch last time before going down the list did the trick.

I use cmdstanr to avoid the Toolchain configuration.