Errors Installing R Libraries for AFNI on MacOS

Hello! I am currently in the process of installing AFNI on my computer (MacOS
14.6.1, M3). I am running into some errors when installing the R packages. I
have been using this tutorial:
https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/background_install/install_instructs/steps_macOS_12_Silicon_old.html

When running the command to install R Libraries, I am met with this message:
ERROR: dependency ‘MatrixModels’ is not available for package
‘quantreg’

  • removing ‘/Users/ganeshramsr/Library/R/3.6/library/quantreg’
    ERROR: dependencies ‘pbkrtest’, ‘quantreg’ are not available for
    package ‘car’
  • removing ‘/Users/ganeshramsr/Library/R/3.6/library/car’
    ERROR: dependencies ‘pbkrtest’, ‘car’ are not available for package
    ‘afex’
  • removing ‘/Users/ganeshramsr/Library/R/3.6/library/afex’
    ERROR: dependency ‘car’ is not available for package ‘phia’
  • removing ‘/Users/ganeshramsr/Library/R/3.6/library/phia’

The downloaded source packages are in
‘/private/var/folders/2j/p_56lnvd7t99k3q0mm0ly5l8_6s8mt/T/RtmpLjLJlQ/downloaded_packages’
Warning messages:
1: In install.packages(c("afex", "phia", "snow", "nlme", "lmerTest"), :
installation of package ‘MatrixModels’ had non-zero exit status
2: In install.packages(c("afex", "phia", "snow", "nlme", "lmerTest"), :
installation of package ‘quantreg’ had non-zero exit status
3: In install.packages(c("afex", "phia", "snow", "nlme", "lmerTest"), :
installation of package ‘car’ had non-zero exit status
4: In install.packages(c("afex", "phia", "snow", "nlme", "lmerTest"), :
installation of package ‘afex’ had non-zero exit status
5: In install.packages(c("afex", "phia", "snow", "nlme", "lmerTest"), :
installation of package ‘phia’ had non-zero exit status

When I run afni_system_check.py -check_all I am given this:

-------------------------------- general ---------------------------------
architecture: 64bit Mach-O
cpu type: arm64
system: Darwin
release: 23.6.0
version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:04 PDT
2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T8122
distribution: 14.6.1
number of CPUs: 8
apparent login shell: bash (current shell is zsh)
shell RC file: .bashrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni : /Users/ganeshramsr/abin/afni
afni version : Precompiled binary macos_10.12_local: Oct 10 2024
: AFNI_24.3.02 'Elagabalus'
AFNI_version.txt : AFNI_24.3.02, macos_10.12_local, Oct 10 2024, official
which python : /opt/homebrew/opt/python/libexec/bin/python
python version : 3.13.0
which R : /usr/local/bin/R
R version : R version 3.6.3 (x86_64-apple-darwin15.6.0)

instances of various programs found in PATH:
afni : 1 (/Users/ganeshramsr/abin/afni)
R : 1
(/Library/Frameworks/R.framework/Versions/3.6/Resources/bin/R)
python : 1
(/opt/homebrew/Cellar/python@3.13/3.13.0_1/Frameworks/Python.framework/Versions/3.13/bin/python3.13)
python2 : 0
python3 : 2

/opt/homebrew/Cellar/python@3.13/3.13.0_1/Frameworks/Python.framework/Versions/3.13/bin/python3.13
/usr/bin/python3

** 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 : /bin/tcsh
tcsh version : 6.21.00
which Xvfb : /opt/X11/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: gamm4!
      These packages are not installed on the computer: data.table!
      These packages are not installed on the computer: paran!
      These packages are not installed on the computer: psych!
      These packages are not installed on the computer: brms!
      These packages are not installed on the computer: corrplot!
      These packages are not installed on the computer: metafor!

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

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

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

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

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

-------------------------------- env vars --------------------------------
PATH =
/opt/homebrew/bin:/opt/homebrew/sbin:/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:/usr/local/laps:/Users/ganeshramsr/abin:/Users/ganeshramsr/abin:/Users/ganeshramsr/abin:/Users/ganeshramsr/abin:/opt/homebrew/opt/python/libexec/bin:/Library/Frameworks/R.framework/Resources:/usr/local/gfortran/bin:/Users/ganeshramsr/abin

PYTHONPATH =
R_LIBS =
LD_LIBRARY_PATH =
DYLD_LIBRARY_PATH (sub-shell) = :/opt/X11/lib/flat_namespace
DYLD_FALLBACK_LIBRARY_PATH (sub-shell) =
CONDA_SHLVL =
CONDA_DEFAULT_ENV =
CC =

----------------------------- 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, flatdir, 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 4 files:

    file             path  flatdir  apsearch        follower
    ---------------  ----  -------  --------        --------
    .cshrc           0     0        1               0
    .tcshrc          0     0        0               1
    .zshrc           0     0        0               0
    .bashrc          0     0        0               0

------------------------------ data checks -------------------------------
data dir : missing AFNI_data6
data dir : missing AFNI_demos
data dir : missing suma_demo
data dir : missing afni_handouts
atlas : found TT_N27+tlrc under /Users/ganeshramsr/abin

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

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

++ found 1 dylib files under '/opt/X11/lib/flat_namespace'
-- found 'libXt' dylib files:
/opt/X11/lib/flat_namespace/libXt.6.dylib
-- recent OS X, cheating to check DYLD_LIBRARY_PATH in cur shell 'zsh'...
++ found evar DYLD_LIBRARY_PATH = :/opt/X11/lib/flat_namespace
-- recent OS X, cheating to check DYLD_LIBRARY_PATH in shell 'tcsh'...
++ found evar DYLD_LIBRARY_PATH = /opt/X11/lib/flat_namespace

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

  • just be aware: login shell 'bash', 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)
  • dot file test : want 1 modifications across 4 files:
  • insufficient data for AFNI bootcamp
    (see "Prepare for Bootcamp" on install pages)
  • consider installing gcc under homebrew
  • consider installing glib under homebrew

Do I need these packages to continue with installation or are these missing
packages under MacOS? Is there another issue with installation I need to fix
before proceeding?

This may be the same problem recently addressed here:

Hi, thank you for your response! I actually haven't made it past the section " Install R Libraries." Also, I am not sure I understand the solution in the linked response. Thank you!

Your R version (3.6.3) is quite outdated. Update it to a recent version before attempting to install those packages.

Gang Chen

When I look at R directly it says I'm running version 4.4.1, but the install directions for AFNI install R version 3.6.3

What is the output of the following commands?

R --version
ls -l /usr/local/bin/R
ls -l /Library/Frameworks/R.framework/Resources
ls -l /Library/Frameworks/R.framework/Versions/

Gang Chen

I noticed you are looking at the old instructions. Try these instructions instead.

https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/background_install/install_instructs/steps_macOS_12_Silicon.html

lrwxr-xr-x 1 root wheel 47 Oct 23 15:06 /usr/local/bin/R -> /Library/Frameworks/R.framework/Resources/bin/R
ndsd-bnu-2765:~ ganeshramsr$ ls -l /Library/Frameworks/R.framework/Resources
lrwxrwxr-x 1 root admin 26 Oct 23 15:06 /Library/Frameworks/R.framework/Resources -> Versions/Current/Resources
ndsd-bnu-2765:~ ganeshramsr$ ls -l /Library/Frameworks/R.framework/Versions/
total 0
drwxrwxr-x 6 root admin 192 Oct 15 11:31 3.6
drwxrwxr-x 6 root admin 192 Oct 23 15:06 4.3-arm64
drwxrwxr-x 3 root admin 96 Oct 23 15:06 4.4-arm64
lrwxrwxr-x 1 root admin 9 Oct 23 15:06 Current -> 4.3-arm64

Hi, I uninstalled and reinstalled R and retried the install process using the instructions you linked and am still receiving an error after running afni_system_check.py -check_all

------------------------------- general ---------------------------------
architecture:         64bit Mach-O
cpu type:             arm64
system:               Darwin
release:              23.6.0
version:              Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:04 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T8122
distribution:         14.6.1
number of CPUs:       8
apparent login shell: bash
shell RC file:        .bashrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni           : /Users/ganeshramsr/abin/afni
afni version         : Precompiled binary macos_10.12_local: Oct 10 2024 
                     : AFNI_24.3.02 'Elagabalus'
AFNI_version.txt     : AFNI_24.3.02, macos_10.12_local, Oct 10 2024, official
which python         : /opt/homebrew/opt/python/libexec/bin/python
python version       : 3.13.0
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/ganeshramsr/abin/afni)
    R       : 1   (/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/bin/R)
    python  : 1   (/opt/homebrew/Cellar/python@3.13/3.13.0_1/Frameworks/Python.framework/Versions/3.13/bin/python3.13)
    python2 : 0 
    python3 : 2 
      /opt/homebrew/Cellar/python@3.13/3.13.0_1/Frameworks/Python.framework/Versions/3.13/bin/python3.13
      /usr/bin/python3

** 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           : /bin/tcsh
tcsh version         : 6.21.00
which Xvfb           : /opt/X11/bin/Xvfb

checking for R packages...
    rPkgsInstall -pkgs ALL -check : FAILURE
        Error in dyn.load(ll) : 
          unable to load shared object '/Users/ganeshramsr/abin/R_io.so':
          dlopen(/Users/ganeshramsr/abin/R_io.so, 0x0006): tried: '/Users/ganeshramsr/abin/R_io.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/ganeshramsr/abin/R_io.so' (no such file), '/Users/ganeshramsr/abin/R_io.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))
        Calls: source ... withVisible -> eval -> eval -> set_R_io -> dyn.load
        Execution halted

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

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

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

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

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

-------------------------------- env vars --------------------------------
PATH                       = /opt/homebrew/bin:/opt/homebrew/sbin:/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:/usr/local/laps:/Users/ganeshramsr/abin:/opt/homebrew/opt/python/libexec/bin

PYTHONPATH                 = 
R_LIBS                     = /Users/ganeshramsr/sw/R-4.3.1
LD_LIBRARY_PATH            = 
DYLD_LIBRARY_PATH (sub-shell) = :/opt/X11/lib/flat_namespace
DYLD_FALLBACK_LIBRARY_PATH (sub-shell) = 
CONDA_SHLVL                = 
CONDA_DEFAULT_ENV          = 
CC                         = 

----------------------------- 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, flatdir, 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 : missing AFNI_data6
data dir : missing AFNI_demos
data dir : missing suma_demo
data dir : missing afni_handouts
atlas    : found TT_N27+tlrc  under /Users/ganeshramsr/abin

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

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

++ found 1 dylib files under '/opt/X11/lib/flat_namespace'
   -- found 'libXt' dylib files:
      /opt/X11/lib/flat_namespace/libXt.6.dylib
-- recent OS X, cheating to check DYLD_LIBRARY_PATH in cur shell 'bash'...
++ found evar DYLD_LIBRARY_PATH = :/opt/X11/lib/flat_namespace
-- recent OS X, cheating to check DYLD_LIBRARY_PATH in shell 'tcsh'...
++ found evar DYLD_LIBRARY_PATH = /opt/X11/lib/flat_namespace

=========================  summary, please fix:  =========================
*  just be aware: login shell 'bash', 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)
*  insufficient data for AFNI bootcamp
   (see "Prepare for Bootcamp" on install pages)
*  consider installing gcc under homebrew
*  consider installing glib under homebrew

Hopefully you have installed the homebrew packages mentioned in Daniel's link. So now it would be good to get away from that macos_10.12_local package, since it is not appropriate for that system.

Would you please run this and post the output text (it takes a while to compile AFNI):

@update.afni.binaries -build_afni -package macos_13_ARM

Thanks,

  • rick