how to install brms on Ubuntu 20.04?

Dear AFNI Gurus-

I followed the main installation instructions here for AFNI on a fresh, new Ubuntu 20.04 OS:
https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/background_install/install_instructs/steps_linux_ubuntu20.html
But I am missing the “brms” package for R. How can I install it?

Here is my system check output:


-------------------------------- general ---------------------------------
architecture:         64bit 
system:               Linux
release:              5.11.0-34-generic
version:              #36~20.04.1-Ubuntu SMP Fri Aug 27 08:06:32 UTC 2021
distribution:         debian bullseye/sid 
number of CPUs:       8
apparent login shell: bash
shell RC file:        .bashrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni           : /home/ptaylor/afni_build/src/linux_ubuntu_16_64_glw_local_shared/afni
afni version         : Precompiled binary linux_ubuntu_16_64_glw_local_shared: Sep 21 2021 
                     : AFNI_21.2.07 'Nerva'
AFNI_version.txt     : AFNI_21.2.07, linux_ubuntu_16_64_glw_local_shared, Sep 21 2021
which python         : /home/ptaylor/miniconda3/envs/py37_afni_jup_sph/bin/python
python version       : 3.7.9
which R              : /usr/bin/R
R version            : R version 3.6.3 (2020-02-29) -- "Holding the Windsock"
which tcsh           : /usr/bin/tcsh

instances of various programs found in PATH:
    afni    : 1   (/home/ptaylor/afni_build/src/linux_ubuntu_16_64_glw_local_shared/afni)
    R       : 1   (/usr/bin/R)
    python  : 2 
      /home/ptaylor/miniconda3/envs/py37_afni_jup_sph/bin/python3.7
      /usr/bin/python3.8
    python2 : 1   (/usr/bin/python2.7)
    python3 : 2 
      /home/ptaylor/miniconda3/envs/py37_afni_jup_sph/bin/python3.7
      /usr/bin/python3.8


testing ability to start various programs...
    afni                 : success
    suma                 : success
    3dSkullStrip         : success
    uber_subject.py      : success
    3dAllineate          : success
    3dRSFC               : success
    SurfMesh             : success
    3dClustSim           : success
    3dMVM                : success

checking for R packages...
    rPkgsInstall -pkgs ALL -check : FAILURE
        
        oo Warning: 
           These packages are not installed on the computer: brms!
        

R RHOME : /usr/lib/R

checking for $HOME files...
    .afnirc                   : found
    .sumarc                   : found
    .afni/help/all_progs.COMP : found

------------------------------ python libs -------------------------------
** failed to load module PyQt4
-- PyQt4 is no longer needed for an AFNI bootcamp

++ module loaded: matplotlib.pyplot
   module file : /home/ptaylor/miniconda3/envs/py37_afni_jup_sph/lib/python3.7/site-packages/matplotlib/pyplot.py

-------------------------------- env vars --------------------------------
PATH = /home/ptaylor/miniconda3/envs/py37_afni_jup_sph/bin:/home/ptaylor/miniconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/ptaylor/afni_build/src/linux_ubuntu_16_64_glw_local_shared

PYTHONPATH = 
R_LIBS = /home/ptaylor/R

LD_LIBRARY_PATH = 
DYLD_LIBRARY_PATH = 
DYLD_FALLBACK_LIBRARY_PATH = 

------------------------------ data checks -------------------------------
data dir : found AFNI_data6   under $HOME
           top history: 20 Feb 2020 [rickr]: updated FT_analysis examples
data dir : found AFNI_demos   under $HOME
           top history: ...ct 2020 [taylorp]: updated scripts under FATCAT_DEMO
data dir : found suma_demo    under $HOME
           top history: ...s_New/data/Build_tmp on Mon Mar  4 11:56:45 EST 2013
data dir : found afni_handouts under $HOME
atlas    : did not find TT_N27+tlrc

------------------------------ OS specific -------------------------------
which apt-get        : /usr/bin/apt-get
apt-get version      : apt 2.0.6 (amd64)


=========================  summary, please fix:  =========================
*  just be aware: login shell 'bash', but our code examples use 'tcsh'
*  missing R packages (see rPkgsInstall)
*  possibly missing atlases

Grazie,
pt

I just had a similar headache because of some system updates on Ubuntu 20.04. After a long meandering path, I eventually managed to sort out all the hiccups.

Try the following command inside R:


install.packages("Rcpp", dependencies = TRUE, INSTALL_opts = '--no-lock')
install.packages("brms", dependencies = TRUE, INSTALL_opts = '--no-lock')

Paste here the error message in case that occurs.

Thanks, Gang, but I still get a few error messages (below).

From successive building failures and then googling around for more help (including here: https://discourse.mc-stan.org/t/error-when-installing-rstan-on-ubuntu-20-04/23774/4), I found that I first had to run the following in the Linux terminal to install extra dependencies:


sudo add-apt-repository ppa:marutter/rrutter4.0

sudo add-apt-repository -y "ppa:marutter/c2d4u3.5"

sudo apt-get install -y libgdal-dev libopenblas-dev libnode-dev \
                        libudunits2-dev libgfortran4

… and then run this in R:


> install.packages(c("Rcpp","brms"), dependencies = TRUE, INSTALL_opts = '--no-lock')

Hopefully this helps future generations.

And just so people see my OS information (it seems like each version of OS needs to do something different. Sigh.):


$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.3 LTS
Release:	20.04
Codename:	focal

–pt

--------------------------- some early failure messages -----------------------------------------


** R
** demo
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error: package or namespace load failed for ‘igraph’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/ptaylor/R/igraph/libs/igraph.so':
  libopenblas.so.0: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/ptaylor/R/igraph’
* installing *source* package ‘V8’ ...
** package ‘V8’ successfully unpacked and MD5 sums checked
staged installation is only possible with locking
** using non-staged installation
Found C++14 compiler: g++
Using CXXCPP=g++ -std=gnu++14 -E
Using PKG_CFLAGS=-I/usr/include/v8 -I/usr/include/v8-3.14
Using PKG_LIBS=-lv8 -lv8_libplatform
-----------------------------[ ANTICONF ]-------------------------------
Configuration failed to find the libv8 engine library. Try installing:
 * deb: libv8-dev or libnode-dev (Debian / Ubuntu)
 * rpm: v8-devel (Fedora, EPEL)
 * brew: v8 (OSX)
 * csw: libv8_dev (Solaris)
Alternatively, on Linux (x86_64) or MacOS you can set environment variable:
    DOWNLOAD_STATIC_LIBV8=1
to automatically download a static version of libv8.
To use a custom libv8, set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
---------------------------[ ERROR MESSAGE ]----------------------------
<stdin>:1:10: fatal error: v8.h: No such file or directory
compilation terminated.
------------------------------------------------------------------------
ERROR: configuration failed for package ‘V8’
* removing ‘/home/ptaylor/R/V8’
* installing *source* package ‘units’ ...
** package ‘units’ successfully unpacked and MD5 sums checked
staged installation is only possible with locking
** using non-staged installation
configure: units: 0.7-2
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ -std=gnu++11 accepts -g... yes
checking how to run the C++ preprocessor... g++ -std=gnu++11 -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for stdbool.h that conforms to C99... no
checking for _Bool... no
checking for error_at_line... yes
checking for gcc... gcc -std=gnu99
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking for XML_ParserCreate in -lexpat... yes
checking udunits2.h usability... no
checking udunits2.h presence... no
checking for udunits2.h... no
checking udunits2/udunits2.h usability... no
checking udunits2/udunits2.h presence... no
checking for udunits2/udunits2.h... no
checking for ut_read_xml in -ludunits2... no
configure: error: in `/tmp/RtmpsWVzDl/R.INSTALL19b2a3eb4d83c/units':
configure: error: 
--------------------------------------------------------------------------------
  Configuration failed because libudunits2.so was not found. Try installing:
    * deb: libudunits2-dev (Debian, Ubuntu, ...)
    * rpm: udunits2-devel (Fedora, EPEL, ...)
    * brew: udunits (OSX)
  If udunits2 is already installed in a non-standard location, use:
    --configure-args='--with-udunits2-lib=/usr/local/lib'
  if the library was not found, and/or:
    --configure-args='--with-udunits2-include=/usr/include/udunits2'
  if the header was not found, replacing paths with appropriate values.
  You can alternatively set UDUNITS2_INCLUDE and UDUNITS2_LIBS manually.
--------------------------------------------------------------------------------

See `config.log' for more details
ERROR: configuration failed for package ‘units’
* removing ‘/home/ptaylor/R/units’
ERROR: dependency ‘igraph’ is not available for package ‘threejs’
* removing ‘/home/ptaylor/R/threejs’
ERROR: dependency ‘units’ is not available for package ‘sf’
* removing ‘/home/ptaylor/R/sf’
ERROR: dependency ‘V8’ is not available for package ‘rstan’
* removing ‘/home/ptaylor/R/rstan’
ERROR: dependencies ‘rstan’, ‘threejs’ are not available for package ‘shinystan’
* removing ‘/home/ptaylor/R/shinystan’
ERROR: dependencies ‘sf’, ‘units’ are not available for package ‘spdep’
* removing ‘/home/ptaylor/R/spdep’
ERROR: dependencies ‘rstan’, ‘shinystan’ are not available for package ‘brms’
* removing ‘/home/ptaylor/R/brms’

The downloaded source packages are in
	‘/tmp/RtmpJMddu0/downloaded_packages’
Warning messages:
1: In install.packages("brms", dependencies = TRUE, INSTALL_opts = "--no-lock") :
  installation of package ‘igraph’ had non-zero exit status
2: In install.packages("brms", dependencies = TRUE, INSTALL_opts = "--no-lock") :
  installation of package ‘V8’ had non-zero exit status
3: In install.packages("brms", dependencies = TRUE, INSTALL_opts = "--no-lock") :
  installation of package ‘units’ had non-zero exit status
4: In install.packages("brms", dependencies = TRUE, INSTALL_opts = "--no-lock") :
  installation of package ‘threejs’ had non-zero exit status
5: In install.packages("brms", dependencies = TRUE, INSTALL_opts = "--no-lock") :
  installation of package ‘sf’ had non-zero exit status
6: In install.packages("brms", dependencies = TRUE, INSTALL_opts = "--no-lock") :
  installation of package ‘rstan’ had non-zero exit status
7: In install.packages("brms", dependencies = TRUE, INSTALL_opts = "--no-lock") :
  installation of package ‘shinystan’ had non-zero exit status
8: In install.packages("brms", dependencies = TRUE, INSTALL_opts = "--no-lock") :
  installation of package ‘spdep’ had non-zero exit status
9: In install.packages("brms", dependencies = TRUE, INSTALL_opts = "--no-lock") :
  installation of package ‘brms’ had non-zero exit status
>

I jumped through many hoops, but I don’t recall installing the few dependencies you mentioned. Instead, I executed the following to resolve the issue related to the R packages such as “units” and “sf” in your error list:


sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
sudo apt-get install libudunits2-dev libgdal-dev libgeos-dev libproj-dev