R wrapper scripts error

I'm not sure what I changed, but R-wrapper scripts (e.g., 3dMVM, 3dISC) have suddenly stopped working for me, giving this error: ERROR: Failed to load R_io.so. Below is the output of afni_system_check.py -check_all. Re-compiling fails with this error:

ld: warning: -single_module is obsolete
ld: warning: -multiply_defined is obsolete
ld: library 'iconv' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [/Library/Frameworks/R.framework/Resources/share/make/shlib.mk:10: R_io.so] Error 1
make[1]: Leaving directory '/Users/bkirwan/afni_build/build_src'
make: *** [Makefile.INCLUDE:4244: R_io.so] Error 1

Any ideas?

afni_system_check.py -check_all 


-------------------------------- general ---------------------------------
architecture:         64bit 
cpu type:             arm64
system:               Darwin
release:              24.4.0
version:              Darwin Kernel Version 24.4.0: Fri Apr 11 18:33:40 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6031
distribution:         15.4.1
number of CPUs:       14
user:                 bkirwan
apparent login shell: zsh
shell RC file:        .zshrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni           : /Users/bkirwan/abin/afni
afni version         : Precompiled binary macos_13_ARM: Apr 28 2025 
                     : AFNI_25.1.05 'Maximinus'
AFNI_version.txt     : AFNI_25.1.05, macos_13_ARM, Apr 28 2025, official
which python         : /Users/bkirwan/fsl/bin/python
python version       : 3.11.8
which R              : /usr/local/bin/R
R version            : R version 4.3.1 (aarch64-apple-darwin20)

instances of various programs found in PATH:
    afni    : 1   (/Users/bkirwan/abin/afni)
    R       : 1   (/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/bin/R)
    python  : 2 
      /Users/bkirwan/fsl/bin/python3.11
      /opt/homebrew/Cellar/python@3.13/3.13.3/Frameworks/Python.framework/Versions/3.13/bin/python3.13
    python2 : 0 
    python3 : 3 
      /Users/bkirwan/fsl/bin/python3.11
      /opt/homebrew/Cellar/python@3.13/3.13.3/Frameworks/Python.framework/Versions/3.13/bin/python3.13
      /usr/bin/python3

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
        Warning message:
        package ‘data.table’ was built under R version 4.3.3 
    rPkgsInstall         : FAILURE
        

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

which tcsh           : /bin/tcsh
tcsh version         : 6.21.00
which Xvfb           : /opt/X11/bin/Xvfb

checking for R packages...
    rPkgsInstall -pkgs ALL -check : FAILURE
        

R RHOME : /Library/Frameworks/R.framework/Resources

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

** failed to load module matplotlib.pyplot
-- matplotlib.pyplot is required

++ module loaded: flask
   module file : /Users/bkirwan/fsl/lib/python3.11/site-packages/flask/__init__.py
   flask version : 3.0.3

++ module loaded: flask_cors
   module file : /Users/bkirwan/fsl/lib/python3.11/site-packages/flask_cors/__init__.py
   flask_cors version : 5.0.0

-------------------------------- env vars --------------------------------
PATH                       = /Applications/freesurfer/7.4.1/bin:/Applications/freesurfer/7.4.1/fsfast/bin:/Users/bkirwan/fsl/bin:/Users/bkirwan/fsl/share/fsl/bin:/Applications/freesurfer/7.4.1/mni/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/bkirwan/fsl/share/fsl/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/opt/X11/bin:/opt/homebrew/opt/python/libexec/bin:/Users/bkirwan/abin:/Applications/MeshLab2023.12.app/Contents/MacOS

PYTHONPATH                 = 
R_LIBS                     = /Users/bkirwan/sw/R-4.3.1
LD_LIBRARY_PATH            = 
DYLD_LIBRARY_PATH (sub-shell) = /Applications/freesurfer/7.4.1/lib/gcc/lib:/opt/X11/lib/flat_namespace
DYLD_FALLBACK_LIBRARY_PATH (sub-shell) = /Users/bkirwan/abin
CONDA_SHLVL                = 
CONDA_DEFAULT_ENV          = 
CC                         = 
HOMEBREW_PREFIX            = /opt/homebrew

----------------------------- 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)
   
   no modifications needed across 3 dot files
   
------------------------------ data checks -------------------------------
data dir : found AFNI_data6   under $HOME/AFNI_bootcamp (948584M Avail)
           top history: ... 2024 [rickr]: 3drefit -newid FT/SUMA/FT_SurfVol.nii
data dir : found AFNI_demos   under $HOME/AFNI_bootcamp
           top history: ...2 Oct 2024 [rickr]: regenerated the AFNI_pamenc tree
data dir : found suma_demo    under $HOME/AFNI_bootcamp
           top history: ...s_New/data/Build_tmp on Mon Mar  4 11:56:45 EST 2013
data dir : found afni_handouts under $HOME/AFNI_bootcamp
atlas    : found TT_N27+tlrc  under /Users/bkirwan/abin

------------------------------ OS specific -------------------------------
XQuartz version      : 2.8.5

which brew           : /opt/homebrew/bin/brew
brew version         : Homebrew 4.5.0

which git            : /usr/bin/git
git version          : git version 2.39.5 (Apple Git-154)
which gcc            : /usr/bin/gcc
gcc version          : Apple clang version 17.0.0 (clang-1700.0.13.3)

brew gcc(s)          : /opt/homebrew/bin/gcc-13
                       /opt/homebrew/bin/gcc-14
CommandLineTools SDK : MacOSX15.4.sdk

=========================  summary, please fix:  =========================
*  just be aware: login shell 'zsh', but our code examples use 'tcsh'
*  AFNI programs show FAILURE
*  missing R packages (see rPkgsInstall)
*  python library matplotlib is required
   (see AFNI install docs for details)

Howdy-

macOS is a somewhat finicky system. On macOS, if you use precompiled AFNI binaries (which is what your system check shows), then your R version has to match the build system R version. That can be burdensome. We typically recommend that folks with macOS systems compile AFNI locally, as described here for ARM architecture systems like yours. If you build locally, then the compiled R_io.so version should match that of your system automatically.

You mentioned "recompiling", but does that mean really compiling the binaries, or updating the local version of precompiled binaries (which is how it appears)?

Note that the system check also shows you are missing Python's Matplotlib module on your system, which will be handy to have.

--pt

By "recompile" I meant remove the precompiled version and try to compile again locally, but got errors. I've successfully compiled locally on this machine in the past, and the R scripts worked then, but they suddenly stopped working and thew the Failed to load R_io.so error, so i thought I'd try the precompiled version.

Yes, there seems to have been some issue with R_io.so, and it is not recent. I will dig into this a bit.
For now, try updating that file and see if it helps:

@update.afni.binaries -prog_list R_io.so

-rick

hey! that seems to have worked. 3dMVM runs now. Thanks!

That will help use the official binaries (and I still need to look into why R_io.so was not there to begin with), but not your local compile.
For your local build, it is strange that you did not have libiconv. You might verify that your system is up to date, as well as homebrew.

brew update
brew upgrade
brew install libiconv

And if you actually need to install libiconv, you might need others as well.

Paul noted that you are running R 4.3.1, but your R libraries are from 4.3.3. To continue using those libraries, it would be necessary to go back to compiling AFNI locally. And if you actually try to update those libraries, you may be forced to go to R 4.4...

-rick

It turned out that we have not built macos_13_ARM R_io.so since December.
I had recreated that build machine, but neglected to put /usr/local/bin in the path for tcsh.

Now those binaries have been regenerated, and they do have R_io.so.

Thanks for reporting this.
-rick

1 Like