R installation issues affecting group analysis

Hello,

I'm encountering issues when trying to run groupAna_cases specifically implemented by R (I'm not sure if all cases are implemented by R).

I've read several other threads that encounter a similar issue but only one seemed relevant to my issue, although it's not like mine in perhaps important ways. I updated my R binaries and my afni_system_check outputs the following R issues since:

3dMVM                : FAILURE
    Error in library(data.table) : there is no package called ‘data.table’
    Calls: source ... suppressPackageStartupMessages -> withCallingHandlers -> library
    Execution halted
rPkgsInstall         : FAILURE
    Error in dyn.load(ll) :
      unable to load shared object '/usr/lib/afni/bin/R_io.so':
      libpng12.so.0: cannot open shared object file: No such file or directory
    Calls: source ... withVisible -> eval -> eval -> set_R_io -> dyn.load
    Execution halted

I assume the missing R packages are what are causing my issue. I can't run 3dMSS and 3dMVM given the issue. I'm not sure the issues I've read relating to R_io apply to my own since I can't install packages after the binary update:

tlab@thc:/usr/local/abin$ rPkgsInstall -pkgs "gamm4,snow"

oo Warning:
Failed to load R_io.so with this error message:
/usr/lib/afni/bin/R_io.so
Error in dyn.load(ll) :
unable to load shared object '/usr/lib/afni/bin/R_io.so':
libpng12.so.0: cannot open shared object file: No such file or directory
Calls: source ... withVisible -> eval -> eval -> set_R_io -> dyn.load
Execution halted

Here's the complete system_check output:

-------------------------------- general ---------------------------------
architecture:         64bit ELF
cpu type:             x86_64
system:               Linux
release:              5.15.0-144-generic
version:              #157-Ubuntu SMP Mon Jun 16 07:33:10 UTC 2025
distribution:         ubuntu 22.04 Jammy Jellyfish
number of CPUs:       16
user:                 tlab
apparent login shell: bash
shell RC file:        .bashrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni           : /usr/local/abin/afni
afni version         : Precompiled binary linux_ubuntu_16_64: Sep 29 2025
: AFNI_25.2.18 'Gordian I'
AFNI_version.txt     : AFNI_25.2.18, linux_ubuntu_16_64, Sep 29 2025, official
afnipy version       : AFNI_25.2.18
which python         : /usr/share/fsl/5.0/bin/python
python version       : 3.11.8
which R              : /usr/bin/R
R version            : R version 4.5.2 (x86_64-pc-linux-gnu)

instances of various programs found in PATH:
afni    : 1   (/usr/local/abin/afni)
(owned by root)
R       : 1   (/usr/bin/R)
python  : 2
/usr/share/fsl/5.0/bin/python3.11
/usr/bin/python3.10
python2 : 1   (/usr/bin/python2.7)
python3 : 2
/usr/share/fsl/5.0/bin/python3.11
/usr/bin/python3.10

testing ability to start various programs...
afni                 : success
suma                 : success
3dSkullStrip         : success
3dAllineate          : success
3dRSFC               : success
SurfMesh             : success
3dClustSim           : success
build_afni.py        : 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
rPkgsInstall         : FAILURE
Error in dyn.load(ll) :
unable to load shared object '/usr/lib/afni/bin/R_io.so':
libpng12.so.0: cannot open shared object file: No such file or directory
Calls: source ... withVisible -> eval -> eval -> set_R_io -> dyn.load
Execution halted

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

which tcsh           : /usr/bin/tcsh
tcsh version         : 6.21.00
which Xvfb           : /usr/bin/Xvfb

checking for R packages...
rPkgsInstall -pkgs ALL -check : FAILURE
Error in dyn.load(ll) :
unable to load shared object '/usr/lib/afni/bin/R_io.so':
libpng12.so.0: cannot open shared object file: No such file or directory
Calls: source ... withVisible -> eval -> eval -> set_R_io -> dyn.load
Execution halted

R RHOME : /usr/lib/R

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

++ module loaded: matplotlib.pyplot
module file : /usr/share/fsl/5.0/lib/python3.11/site-packages/matplotlib/pyplot.py
matplotlib version : 3.8.4

++ module loaded: flask
module file : /usr/share/fsl/5.0/lib/python3.11/site-packages/flask/**init**.py
flask version : 3.0.3

** failed to load module flask_cors
-- flask_cors is required

-- python binaries under /usr/local/bin:
/usr/local/bin/python2.7

-------------------------------- env vars --------------------------------
PATH                       = /home/tlab/Documents/mrtrix3/bin:/home/tlab/Documents/Mango/bin:/home/tlab/anaconda3/bin:/home/tlab/Documents/Mango/bin:/usr/local/freesurfer/bin:/usr/local/freesurfer/fsfast/bin:/usr/local/freesurfer/tktools:/usr/share/fsl/5.0/bin:/usr/share/fsl/5.0/share/fsl/bin:/usr/local/freesurfer/mni/bin:/usr/lib/fsl/5.0:/home/tlab/anaconda3/bin:/home/tlab/Documents/Mango/bin:/opt/c3d/bin:/usr/share/fsl/5.0/bin:/usr/share/fsl/5.0/share/fsl/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/usr/share/fsl/5.0/bin:/usr/lib/afni/bin:/usr/local/abin:/usr/share/fsl/5.0/bin:/usr/lib/afni/bin:/usr/lib/fsl/5.0:/usr/local/abin:/usr/share/fsl/5.0/bin:/usr/lib/afni/bin:/usr/lib/fsl/5.0:/usr/local/abin

PYTHONPATH                 =
R_LIBS                     = /home/tlab/R
LD_LIBRARY_PATH            = /usr/lib/fsl/5.0
DYLD_LIBRARY_PATH          =
DYLD_FALLBACK_LIBRARY_PATH =
CONDA_SHLVL                =
CONDA_DEFAULT_ENV          =
CC                         =
HOMEBREW_PREFIX            =

----------------------------- 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 (3T Avail)
top history: ...d GroupAna_cases/gen_datatables/ggc_dt_commands.tcsh
data dir : found AFNI_data7   under $HOME
top history: ...025 \[PT/RCR\]: init with do\_ scripts and sub-000 data
data dir : found AFNI_demos   under $HOME
top history: 22 May 2025 \[taylorp\]: update subject QC directories
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 .

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

which git            : /usr/bin/git
git version          : git version 2.34.1
which gcc            : /usr/share/fsl/5.0/bin/gcc
gcc version          : gcc (conda-forge gcc 12.3.0-7) 12.3.0

have Ubuntu system: ubuntu 22.04 Jammy Jellyfish
have Ubuntu afni  : Precompiled binary linux_ubuntu_16_64: Sep 29 2025

=========================  summary, please fix:  =========================

* AFNI programs show FAILURE
* missing R packages (see rPkgsInstall)
* python library flask_cors is required
* dot file test : want 1 modifications across 3 files:

Any advice on how to address this? And thank you for any guidance and time in advance!

Howdy-

Hmm, OK. There appear to be a few different issues here.

From how the PATH variable looks and guessing at variable names, it seems like you have 2 directories with AFNI binaries in them, under:

/usr/local/abin
/usr/lib/afni/bin

Since /usr/lib/afni/bin is first in the PATH, I would have thought that one would get chosen, but the system check output of which afni actually shows that /usr/local/abin/afniis getting priority, at least for where the "afni" program specifically is. **However**, even more confusingly, this error message points to havingR_io.so` being found in the other directory:

unable to load shared object '/usr/lib/afni/bin/R_io.so':

Something nonstandard is happening in the setup here (and the "afni" program is also owned by root), and I'm not sure if various pieces of AFNI code base are split up, because they are being found "first" in the path in different directories? Maybe if would be helpful if you could dump out a list of the contents of each of those directories:

cd 
ls -d /usr/local/abin/* > list_of_local_abin.txt
ls -d /usr/lib/afni/bin/* > list_of_lib_afni_bin.txt

and email list_of*.txt files to me?

Sidenote: From the location of the binaries under /usr/local/*, I guess that this is an administered computer?

I'm not familiar with the libpng12.so.0 file being missing. You can make sure that you have all necessary dependencies for the AFNI binaries by running the commands in this section of the installation docs:
Ubuntu 22.04 dependencies

In terms of R itself, I am not aware of any particular issues with v4.5.2 (I think 4.5.1 actually had some problems). Sometimes for whatever reason it is possible to install R packages directly within R more easily. Could you please try starting an R environment by typing just R, and then within it try to install those missing packages:

install.packages('snow')
install.packages('gamm4')

Also, the Python installation is missing the flask_cors module. It would be good if you could add that to your environment, which is installed under /usr/share/fsl/5.0/bin/python.

--pt

As a follow-up to this, the R issues have been resolved.

The main issue seems to have been having multiple AFNI directories in the $PATH, with some incomplete installations in one case. This created some confusion among libraries/packages, variously in different shells.

We resolved this as follows (with some choices made because it was an administered system): the tarball of the current AFNI binaries for this system was downloaded, unpacked, and renamed to "abin" in the home directory (for convenience); then, we updated the ~/.*rc files for the shells, to remove reference to the previously-existing AFNI directories, and to put in reference to the new ~/abin. After that, we opened a new terminal, and things worked (probably, we could have just removed the path references to the original AFNI binary directories, opened a new terminal and gone through the setup instructions, starting from after the dependencies have been installed.)

The flask_cors module was successfully added to the existing Python environment.

The missing R packages could be installed with install.packages(...).

Phew!

--pt