AFNI install issues (M2)

Hi experts,
I am writing to seek your expertise and assistance with issues I have encountered while attempting to install AFNI for the first time. My system is macOS 13.4.1 with M2 silicon. I have followed the installation instructions provided by AFNI to the best of my abilities, but I have encountered a problem that I have been unable to resolve on my own. After running '/Users/lianqi/abin/afni_system_check.py -check_all', I found the “Please Fix” section showing like below:
========================= summary, please fix: =========================

  • just be aware: login shell 'bash', but our code examples use 'tcsh'
  • shell bash: MISSING non-login setup file .bashrc
  • shell bash: consider sourcing (non-login) .bashrc from (login) .bash_profile
  • AFNI programs show FAILURE
  • please run: cp /Users/lianqi/abin/AFNI.afnirc ~/.afnirc
  • please run: "suma -update_env" for .sumarc
  • please run: apsearch -update_all_afni_help
  • dot file test : want 8 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
  • please set DYLD_LIBRARY_PATH to /opt/X11/lib/flat_namespace in zsh
  • please set DYLD_LIBRARY_PATH to /opt/X11/lib/flat_namespace in tcsh

Could you please give any suggestions?

Best wishes,
Anqi

Yes we can offer suggestions. Could you post the entirety of your afni_system_check.py output? There's a couple things in here that will make more sense once we see the rest.

Thank you for the reply.

the entire output:
-------------------------------- general ---------------------------------
architecture: 64bit
cpu type: arm
system: Darwin
release: 22.5.0
version: Darwin Kernel Version 22.5.0: Thu Jun 8 22:29:35 PDT 2023; root:xnu-8796.121.3~8/RELEASE_ARM64_T6020
distribution: 13.4.1
number of CPUs: 12
apparent login shell: bash
shell RC file: .bashrc (does not exist)

--------------------- AFNI and related program tests ---------------------
which afni :
:
AFNI_version.txt : AFNI_23.2.08, macos_10.12_local, Aug 25 2023, official
which python : /Users/lianqi/anaconda3/envs/work/bin/python
python version : 3.11.4
which R : /Library/Frameworks/R.framework/Resources/R
R version : R version 3.6.3 (2020-02-29) -- "Holding the Windsock"

instances of various programs found in PATH:
afni : 0
R : 1 (/Library/Frameworks/R.framework/Versions/3.6/Resources/bin/R)
python : 3
/Users/lianqi/anaconda3/envs/work/bin/python3.11
/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/bin/python3.11
/Users/lianqi/anaconda3/bin/python3.11
python2 : 0
python3 : 4
/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/bin/python3.11
/Users/lianqi/anaconda3/envs/work/bin/python3.11
/Users/lianqi/anaconda3/bin/python3.11
/usr/bin/python3

** have python3 but not python2

testing ability to start various programs...
afni : FAILURE
/bin/sh: afni: command not found
suma : FAILURE
/bin/sh: suma: command not found
3dSkullStrip : FAILURE
/bin/sh: 3dSkullStrip: command not found
3dAllineate : FAILURE
/bin/sh: 3dAllineate: command not found
3dRSFC : FAILURE
/bin/sh: 3dRSFC: command not found
SurfMesh : FAILURE
/bin/sh: SurfMesh: command not found
3dClustSim : FAILURE
/bin/sh: 3dClustSim: command not found
uber_subject.py : FAILURE
/bin/sh: uber_subject.py: command not found
3dMVM : FAILURE
/bin/sh: 3dMVM: command not found

have failures, testing programs under implied /Users/lianqi/abin...
afni : success
suma : success
3dSkullStrip : success
3dAllineate : success
3dRSFC : success
SurfMesh : success
3dClustSim : success
uber_subject.py : success
3dMVM : success

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

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

checking for R packages...
rPkgsInstall -pkgs ALL -check : FAILURE
/bin/sh: rPkgsInstall: command not found

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

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

++ module loaded: matplotlib.pyplot
module file : /Users/lianqi/anaconda3/envs/work/lib/python3.11/site-packages/matplotlib/pyplot.py
matplotlib version : 3.7.2

-------------------------------- env vars --------------------------------
PATH = /Users/lianqi/fsl/share/fsl/bin:/Users/lianqi/fsl/share/fsl/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/lianqi/anaconda3/envs/work/bin:/Users/lianqi/anaconda3/condabin:/usr/local/gfortran/bin:/Library/Frameworks/R.framework/Resources:/opt/homebrew/opt/python/libexec/bin:/Users/lianqi/ants-2.4.4/bin:/Library/Java/JavaVirtualMachines/jdk-20.jdk/Contents/Home/bin:/Users/lianqi/MATLAB_R2023a.app/bin:/Users/lianqi/freesurfer/bin:/Users/lianqi/freesurfer/fsfast/bin:/Users/lianqi/freesurfer/mni/bin:/Users/lianqi/anaconda3/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/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:.

PYTHONPATH =
R_LIBS =
LD_LIBRARY_PATH =
DYLD_LIBRARY_PATH (sub-shell) =
DYLD_FALLBACK_LIBRARY_PATH (sub-shell) =

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

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

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

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

init_user_dotfiles.py: Command not found.
------------------------------ data checks -------------------------------
data dir : missing AFNI_data6
data dir : missing AFNI_demos
data dir : missing suma_demo
data dir : missing afni_handouts
atlas : did not find TT_N27+tlrc

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

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

++ 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'...
** env var DYLD_LIBRARY_PATH not set to contain /opt/X11/lib/flat_namespace
-- recent OS X, cheating to check DYLD_LIBRARY_PATH in shell 'tcsh'...
** env var DYLD_LIBRARY_PATH not set to contain /opt/X11/lib/flat_namespace

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

  • just be aware: login shell 'bash', but our code examples use 'tcsh'
  • shell bash: MISSING non-login setup file .bashrc
  • shell bash: consider sourcing (non-login) .bashrc from (login) .bash_profile
  • missing program: afni
  • failure under initial "AFNI and related program tests"
  • AFNI programs show FAILURE
  • consider adding /Users/lianqi/abin to your PATH
  • missing R packages (see rPkgsInstall)
  • please run: "suma -update_env" for .sumarc
  • please run: apsearch -update_all_afni_help
  • failure running init_user_dotfiles.py -test
  • insufficient data for AFNI bootcamp
    (see "Prepare for Bootcamp" on install pages)
  • possibly missing atlases
  • consider installing gcc under homebrew
  • consider installing glib under homebrew
  • please set DYLD_LIBRARY_PATH to /opt/X11/lib/flat_namespace in bash
  • please set DYLD_LIBRARY_PATH to /opt/X11/lib/flat_namespace in tcsh

Hello,

The first hurdle is that AFNI does not appear to be in your path. Since your login shell is bash you can do:

echo "PATH=$PATH:/Users/lianqi/abin/" >> ~/.bashrc

Then close and open the terminal. You can then use init_user_dotfiles.py (help here) to configure the rest of the shell.

init_user_dotfiles.py -test

And then further updates can be made with some variation of:

init_user_dotfiles.py -do_updates ALL

Thank you for your advice. After I added the path, some problems were solved.
However, when I run: init_user_dotfiles.py -do_updates ALL, I met the erro:
** failed to open text file '.tcshrc' for writing

** error: failed to append shell text to file .tcshrc

the output of init_user_dotfiles.py -test:
-- no .cshrc, will create one as a follower of .tcshrc
-- 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 10 modifications across 5 files:

file path flatdir apsearch follower


.bashrc 0 1 1 0
.cshrc 0 0 0 1
.tcshrc 1 1 1 0
.profile 1 1 1 0
.zshrc 0 1 1 0

That's interesting - seems to suggest you don't have permissions on your .tcshrc. Can check by doing:

ls -al ~/.tcshrc

Although that shouldn't matter as much since you're using bash as your login shell.

What other errors are you seeing in afni_system_check?

Thanks for your patience! the output of afni_system_check:
========================= 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
  • missing R packages (see rPkgsInstall)
  • please run: "suma -update_env" for .sumarc
  • please run: apsearch -update_all_afni_help
  • dot file test : want 3 modifications across 3 files:
  • insufficient data for AFNI bootcamp
    (see "Prepare for Bootcamp" on install pages)
  • please set DYLD_LIBRARY_PATH to /opt/X11/lib/flat_namespace in tcsh

maybe this is caused by " insufficient data for AFNI bootcamp"?

Looks like most things should be working. It's just telling you that the AFNI bootcamp data isn't downloaded (https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/background_install/bootcamp_stuff.html). If you post the full report then I can look for other things.

Otherwise I'd say happy analyzing and let us know if anything breaks.

unfortunately i failed to open afni gui by running: "afni"

the output:
Precompiled binary macos_10.12_local: Aug 25 2023 (Version AFNI_23.2.08 'Marcus Didius Severus Julianus')

** Version check disabled: AFNI_VERSION_CHECK forbids
Thanks go to JA Butman for useful feedback

Initializing: X11
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++ If you are using XQuartz 2.7.10 (or later), and AFNI crashes when

  • opening windows, or you cannot type text into AFNI popup windows,
  • you might need to set an environment variable to solve this problem:
  • setenv DYLD_LIBRARY_PATH /opt/X11/lib/flat_namespace # tcsh
  • export DYLD_LIBRARY_PATH=/opt/X11/lib/flat_namespace # bash
  • This command is best put in your startup ~/.cshrc file, so that
  • it will be invoked for every (t)csh shell you open (mutatis mutandis
  • for the bash shell, of course).
  • If things are OK and you want to avoid having this warning message
  • pollute your terminal, use this:
  • setenv AFNI_SKIP_DYLD_WARNING YES # tcsh
  • export AFNI_SKIP_DYLD_WARNING=YES # bash

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[The X.Org Foundation v 12101006].
++++++++ IMAGE SAVE SETUP WARNINGS ++++++++
++ Can't find program ffmpeg for Save to MPEG-1
++ To disable these warnings, set environment
++ variable AFNI_IMSAVE_WARNINGS to 'NO'.
+++++++++++++++++++++++++++++++++++++++++++++
Warning: Widget must be a VendorShell.

Fatal Signal 11 (SIGSEGV) received
open_MCW_imseq
SPLASH_popup_image
AFNI_splashup
MAIN_workprocess
AFNI:main
Bottom of Debug Stack
** AFNI version = AFNI_23.2.08 Compile date = Aug 25 2023
** [[Precompiled binary macos_10.12_local: Aug 25 2023]]
** Program Death **
** If you report this crash to the AFNI message board,
** please copy the error messages EXACTLY, and give
** the command line you used to run the program, and
** any other information needed to repeat the problem.
** You may later be asked to upload data to help debug.
** Crash log is appended to file /Users/lianqi/.afni.crashlog
++ AFNI is detached from terminal.

addition: I installed XQuartz (X11) and set an environment variable on bash_profile.

Crash log:
------ CRASH LOG ------------------------------**
Fatal Signal 11 (SIGSEGV) received
.......... recent internal history .........................................
+++++++THD_find_executable [7]: {ENTRY (file=thd_getpathprogs.c line=31) from open_MCW_imseq {6898 ms}
-------THD_find_executable [7]: EXIT} (file=thd_getpathprogs.c line=40) to open_MCW_imseq {6898 ms}
+++++++THD_find_executable [7]: {ENTRY (file=thd_getpathprogs.c line=31) from open_MCW_imseq {6898 ms}
-------THD_find_executable [7]: EXIT} (file=thd_getpathprogs.c line=43) to open_MCW_imseq {6898 ms}
+++++++THD_find_executable [7]: {ENTRY (file=thd_getpathprogs.c line=31) from open_MCW_imseq {6898 ms}
-------THD_find_executable [7]: EXIT} (file=thd_getpathprogs.c line=40) to open_MCW_imseq {6898 ms}
+++++++THD_find_executable [7]: {ENTRY (file=thd_getpathprogs.c line=31) from open_MCW_imseq {6898 ms}
-------THD_find_executable [7]: EXIT} (file=thd_getpathprogs.c line=40) to open_MCW_imseq {6898 ms}
+++++++THD_find_executable [7]: {ENTRY (file=thd_getpathprogs.c line=31) from open_MCW_imseq {6898 ms}
-------THD_find_executable [7]: EXIT} (file=thd_getpathprogs.c line=40) to open_MCW_imseq {6899 ms}
+++++++THD_find_executable [7]: {ENTRY (file=thd_getpathprogs.c line=31) from open_MCW_imseq {6899 ms}
-------THD_find_executable [7]: EXIT} (file=thd_getpathprogs.c line=40) to open_MCW_imseq {6899 ms}
+++++++SPLASH_imseq_getim [7]: {ENTRY (file=afni_splash.c line=442) from open_MCW_imseq {6899 ms}
-------SPLASH_imseq_getim [7]: EXIT} (file=afni_splash.c line=464) to open_MCW_imseq {6899 ms}
+++++++SPLASH_imseq_getim [7]: {ENTRY (file=afni_splash.c line=442) from open_MCW_imseq {6899 ms}
++++++++mri_valpad_2D [8]: {ENTRY (file=mri_zeropad.c line=28) from SPLASH_imseq_getim {6899 ms}
+++++++++mri_new_7D_generic [9]: {ENTRY (file=mri_new.c line=48) from mri_valpad_2D {6899 ms}
---------mri_new_7D_generic [9]: EXIT} (file=mri_new.c line=143) to mri_valpad_2D {6899 ms}
+++++++++mri_add_name [9]: {ENTRY (file=mri_add_name.c line=19) from mri_valpad_2D {6899 ms}
---------mri_add_name [9]: EXIT} (file=mri_add_name.c line=24) to mri_valpad_2D {6899 ms}
--------mri_valpad_2D [8]: EXIT} (file=mri_zeropad.c line=138) to SPLASH_imseq_getim {6899 ms}
-------SPLASH_imseq_getim [7]: EXIT} (file=afni_splash.c line=484) to open_MCW_imseq {6899 ms}
+++++++mri_free [7]: {ENTRY (file=mri_free.c line=49) from open_MCW_imseq {6899 ms}
mri_free -- call killpurge {6899 ms}
++++++++mri_killpurge [8]: {ENTRY (file=mri_purger.c line=259) from mri_free {6899 ms}
mri_killpurge -- check if im==NULL ptr=0x7fa95d6066c0
mri_killpurge -- can't killpurge NULL fname! {6899 ms}
--------mri_killpurge [8]: EXIT} (file=mri_purger.c line=270) to mri_free {6899 ms}
mri_free -- free ptr {6899 ms}
mri_free -- free im {6899 ms}
-------mri_free [7]: EXIT} (file=mri_free.c line=69) to open_MCW_imseq {6899 ms}
............................................................................
open_MCW_imseq
SPLASH_popup_image
AFNI_splashup
MAIN_workprocess
AFNI:main
** AFNI compile date = Aug 25 2023
** [[Precompiled binary macos_10.12_local: Aug 25 2023]]
** Program Crash **

Output of afni_system_check.py:
-------------------------------- general ---------------------------------
architecture: 64bit
cpu type: arm
system: Darwin
release: 22.5.0
version: Darwin Kernel Version 22.5.0: Thu Jun 8 22:29:35 PDT 2023; root:xnu-8796.121.3~8/RELEASE_ARM64_T6020
distribution: 13.4.1
number of CPUs: 12
apparent login shell: bash
shell RC file: .bashrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni : /Users/lianqi/abin/afni
afni version : Precompiled binary macos_10.12_local: Aug 25 2023
: AFNI_23.2.08 'Marcus Didius Severus Julianus'
AFNI_version.txt : AFNI_23.2.08, macos_10.12_local, Aug 25 2023, official
which python : /Users/lianqi/anaconda3/bin/python
python version : 3.11.3
which R : /Library/Frameworks/R.framework/Resources/R
R version : R version 3.6.3 (2020-02-29) -- "Holding the Windsock"

instances of various programs found in PATH:
afni : 1 (/Users/lianqi/abin/afni)
R : 1 (/Library/Frameworks/R.framework/Versions/3.6/Resources/bin/R)
python : 2
/Users/lianqi/anaconda3/bin/python3.11
/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/bin/python3.11
python2 : 0
python3 : 3
/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/bin/python3.11
/Users/lianqi/anaconda3/bin/python3.11
/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 : success

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

which tcsh : /bin/tcsh
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: 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 -------------------------------

++ module loaded: matplotlib.pyplot
module file : /Users/lianqi/anaconda3/lib/python3.11/site-packages/matplotlib/pyplot.py
matplotlib version : 3.7.1

-------------------------------- env vars --------------------------------
PATH = /Users/lianqi/fsl/share/fsl/bin:/Users/lianqi/fsl/share/fsl/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/lianqi/anaconda3/bin:/Users/lianqi/anaconda3/condabin:/usr/local/gfortran/bin:/Library/Frameworks/R.framework/Resources:/opt/homebrew/opt/python/libexec/bin:/Users/lianqi/abin:/Users/lianqi/ants-2.4.4/bin:/Library/Java/JavaVirtualMachines/jdk-20.jdk/Contents/Home/bin:/Users/lianqi/MATLAB_R2023a.app/bin:/Users/lianqi/freesurfer/bin:/Users/lianqi/freesurfer/fsfast/bin:/Users/lianqi/freesurfer/mni/bin:/Users/lianqi/anaconda3/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/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:.

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

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

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

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

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

-- good: .cshrc seems to contain 'source .tcshrc'
-- 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 3 modifications across 3 files:

  file             path  flatdir  apsearch        follower
  ---------------  ----  -------  --------        --------
  .cshrc           0     0        0               1     
  .tcshrc          1     1        1               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/lianqi/abin

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

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

-- consider installing gcc under homebrew
-- consider installing glib under homebrew
++ 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'...
** env var DYLD_LIBRARY_PATH not set to contain /opt/X11/lib/flat_namespace

========================= 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
  • missing R packages (see rPkgsInstall)
  • please run: "suma -update_env" for .sumarc
  • please run: apsearch -update_all_afni_help
  • dot file test : want 3 modifications across 3 files:
  • insufficient data for AFNI bootcamp
    (see "Prepare for Bootcamp" on install pages)
  • please set DYLD_LIBRARY_PATH to /opt/X11/lib/flat_namespace in tcsh

Okay - one more echo:

echo "export DYLD_LIBRARY_PATH=/opt/X11/lib/flat_namespace" >> ~/.bashrc

Also try a reboot, sometimes X11/XQuartz needs that to fully grab hold.

Thank you so much! Finally i can use it on mac.