Difficulty installing dependent R packages for AFNI on Ubuntu 22.04

Hello,

I am having some difficulty installing some of the R package dependencies for AFNI on a Linux system (Ubuntu 22.04). I have looked through some previous threads, but most of the ones I saw fixed the issue by updating the R version to 3.5 or later. My R version is 4.3. When I tried to install the R packages that I'm missing individually, I am getting an error that my C++ compiler is not working. I'm a bit stuck and not sure how to proceed.

afni_system_check.py -check_all:

architecture:         64bit ELF
cpu type:             x86_64
system:               Linux
release:              6.2.0-39-generic
version:              #40~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov 16 10:53:04 UTC 2
distribution:         ubuntu 22.04 Jammy Jellyfish
number of CPUs:       32
apparent login shell: bash
shell RC file:        .bashrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni           : /home/bankslab/abin/afni
afni version         : Precompiled binary linux_ubuntu_16_64: Dec 21 2023 
                     : AFNI_23.3.14 'Septimius Severus'
AFNI_version.txt     : AFNI_23.3.14, linux_ubuntu_16_64, Dec 21 2023, official
which python         : /home/bankslab/fsl/bin/python
python version       : 3.11.6
which R              : /usr/bin/R
R version            : R version 4.3.2 (x86_64-pc-linux-gnu)

instances of various programs found in PATH:
    afni    : 1   (/home/bankslab/abin/afni)
    R       : 1   (/usr/bin/R)
    python  : 3 
      /home/bankslab/fsl/bin/python3.11
      /home/bankslab/miniconda3/bin/python3.11
      /usr/bin/python3.10
    python2 : 0 
    python3 : 3 
      /home/bankslab/fsl/bin/python3.11
      /home/bankslab/miniconda3/bin/python3.11
      /usr/bin/python3.10

** have python3 but not python2

testing ability to start various programs...
    afni                 : success
    suma                 : success
    3dSkullStrip         : success
    3dAllineate          : success
    3dRSFC               : success
    SurfMesh             : success
    3dClustSim           : success
    uber_subject.py      : success
    3dMVM                : FAILURE
        Error in library(data.table) : there is no package called ‘data.table’
        Calls: source ... suppressPackageStartupMessages -> withCallingHandlers -> library
        Execution halted

------------------------ dependent program tests -------------------------
checking for dependent programs...

which tcsh           : /usr/bin/tcsh
which Xvfb           : /usr/bin/Xvfb

checking for R packages...
    rPkgsInstall -pkgs ALL -check : FAILURE
        
        oo Warning: 
           These packages are not installed on the computer: afex!
        These packages are not installed on the computer: phia!
        These packages are not installed on the computer: lmerTest!
        These packages are not installed on the computer: gamm4!
        These packages are not installed on the computer: data.table!
        These packages are not installed on the computer: brms!
        

R RHOME : /usr/lib/R

------------------------------ python libs -------------------------------

++ module loaded: matplotlib.pyplot
   module file : /home/bankslab/fsl/lib/python3.11/site-packages/matplotlib/pyplot.py
   matplotlib version : 3.8.2

++ module loaded: flask
   module file : /home/bankslab/fsl/lib/python3.11/site-packages/flask/__init__.py
   flask version : 3.0.0

** failed to load module flask_cors
-- flask_cors is not required, but is desirable

-------------------------------- env vars --------------------------------
PATH = /home/bankslab/ANTs/:/home/bankslab/freesurfer/bin:/home/bankslab/freesurfer/fsfast/bin:/home/bankslab/freesurfer/tktools:/home/bankslab/fsl/bin:/home/bankslab/fsl/share/fsl/bin:/home/bankslab/freesurfer/mni/bin:/home/bankslab/fsl/share/fsl/bin:/home/bankslab/ANTs:/home/bankslab/freesurfer/bin:/home/bankslab/freesurfer/fsfast/bin:/home/bankslab/freesurfer/tktools:/home/bankslab/fsl/bin:/home/bankslab/fsl/share/fsl/bin:/home/bankslab/freesurfer/mni/bin:/home/bankslab/fsl/share/fsl/bin:/home/bankslab/miniconda3/bin:/home/bankslab/miniconda3/condabin:/home/bankslab/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/usr/local/go/bin:/home/bankslab/fsl/bin:/usr/local/go/bin:/home/bankslab/fsl/bin:/home/bankslab/abin

PYTHONPATH = 
R_LIBS = /home/bankslab/R

LD_LIBRARY_PATH = :/home/bankslab/fsl/lib:/home/bankslab/fsl/lib

DYLD_LIBRARY_PATH = 
DYLD_FALLBACK_LIBRARY_PATH = 

----------------------------- eval dot files -----------------------------

----------- AFNI $HOME files -----------

    .afnirc                   : found
    .sumarc                   : found
    .afni/help/all_progs.COMP : found

--------- shell startup files ----------

   -- good: .tcshrc seems to contain 'source .cshrc'
   -- considered operations: path, apsearch
   
   -- note: followers should not need edits, so edit flags should be 0
      (have 1 follower(s), which can be ignored)
   
   dot file test : want 1 modifications across 3 files:
   
      file             path  flatdir  apsearch        follower
      ---------------  ----  -------  --------        --------
      .cshrc           0     0        1               0     
      .tcshrc          0     0        0               1     
      .bashrc          0     0        0               0     
   
------------------------------ data checks -------------------------------
data dir : found AFNI_data6   under $HOME (467850M Avail)
           top history: ... [gangc]: redo 0.BGA as 1.bga and update run.MSS.txt
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    : found TT_N27+tlrc  under /home/bankslab/abin

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

have Ubuntu system: ubuntu 22.04 Jammy Jellyfish
have Ubuntu afni  : Precompiled binary linux_ubuntu_16_64: Dec 21 2023 

=========================  summary, please fix:  =========================
*  just be aware: login shell 'bash', but our code examples use 'tcsh'
*  shell bash: consider sourcing (non-login) .bashrc from (login) .bash_profile
*  AFNI programs show FAILURE
*  missing R packages (see rPkgsInstall)
*  dot file test : want 1 modifications across 3 files:

rPkgsInstall -pkgs nloptr

Installing package into ‘/home/bankslab/R’
(as ‘lib’ is unspecified)
trying URL 'http://cloud.r-project.org/src/contrib/nloptr_2.0.3.tar.gz'
Content type 'application/x-gzip' length 2219877 bytes (2.1 MB)
==================================================
downloaded 2.1 MB

* installing *source* package ‘nloptr’ ...
** package ‘nloptr’ successfully unpacked and MD5 sums checked
** using staged installation
checking whether the C++ compiler works... no
configure: error: in `/tmp/RtmpLfsdVB/R.INSTALL16498718789c3/nloptr':
configure: error: C++ compiler cannot create executables
See `config.log' for more details
ERROR: configuration failed for package ‘nloptr’
* removing ‘/home/bankslab/R/nloptr’

The downloaded source packages are in
	‘/tmp/RtmpS3pWKs/downloaded_packages’

++ Note:  @ 11:23:31
   	This package has been installed on the computer: nloptr

Warning message:
In install.packages(pkgs_miss, dep = NA, repos = site) :
  installation of package ‘nloptr’ had non-zero exit status

g++ --version

g++ (conda-forge gcc 12.3.0-3) 12.3.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Thanks in advance for the help!

Emma

Hm, I am not sure about what is causing that, that failure seems odd.

On my Ubuntu 20.04, my compiler info is:

$ g++ --version
g++ (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I have a lower version number, so I am doubtful that version number is the issue here. But I notice that our compilers came from different places: mine is from the Ubuntu package manage Aptitude, and yours is from conda-forge. I don't any reason why that would be a problem to install from conda---I hope it isn't---but that is a difference.

My g++ compiler came from the AFNI setup, running the big sudo apt-get install -y ... command. The specific package there that provides gcc/g++ is build-essential, I believe. So, you should probably have that, too.

As a test, could you try deactivating your conda environment (you can always re-enter it later), and try running that command to install the R package? So:

conda deactivate

rPkgsInstall -pkgs nloptr

? That should try using a different g++ on your computer, from Aptitude. Does that still have an issue, or does it work OK?

--pt