AFNI install issue on Mac mini M2 Ventura 13.6.1

Hello, I'm trying to do the quick install on my Mac mini M2 ventura 13.6.1. Everything seemed ok until after the reboot step when running tcsh OS_notes.macos_12_ARM_b_user.tcsh which gave the error:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3521  100  3521    0     0  16500      0 --:--:-- --:--:-- --:--:-- 16530
set os = `uname -s`
uname -s
if ( 0 ) then
if ( Darwin != Darwin ) then
set cpu = `uname -m`
uname -m
if ( 0 ) then
set rver = `R --version | head -n 1 | cut -d ' ' -f 3`
R --version
cut -d   -f 3
head -n 1
if ( 0 ) then
echo OS    : Darwin
OS    : Darwin
echo CPU   : arm64
CPU   : arm64
echo R ver : 4.3.1
R ver : 4.3.1
echo 

defaults write org.macosforge.xquartz.X11 wm_ffm -bool true
defaults write org.x.X11 wm_ffm -bool true
defaults write com.apple.Terminal FocusFollowsMouse -string YES
curl -O https://afni.nimh.nih.gov/pub/dist/bin/misc/@update.afni.binaries
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 53097  100 53097    0     0   204k      0 --:--:-- --:--:-- --:--:--  205k
tcsh @update.afni.binaries -no_recur -package anyos_text_atlas -bindir /Users/jazlynn/abin
-- running @update.afni.binaries version 3.24, December 7, 2023
-- no current AFNI package found in path...
-- any downloads will be from https://afni.nimh.nih.gov via wget

-- attempting to install package anyos_text_atlas under
   install dir: /Users/jazlynn/abin...
-- have install dir
++ working in new temp dir, .tmp.install
-- skipping update of @update.afni.binaries
++ downloading test file: wget anyos_text_atlas/AFNI_version.txt ...
--2024-08-27 23:18:55--  https://afni.nimh.nih.gov/pub/dist/bin/anyos_text_atlas/AFNI_version.txt
Resolving afni.nimh.nih.gov (afni.nimh.nih.gov)... 156.40.187.114
Connecting to afni.nimh.nih.gov (afni.nimh.nih.gov)|156.40.187.114|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 42 [text/plain]
Saving to: 'AFNI_version.txt'

     0K                                                       100% 1000K=0s

2024-08-27 23:18:55 (1000 KB/s) - 'AFNI_version.txt' saved [42/42]

++ no update needed
/Users/jazlynn/abin/init_user_dotfiles.py -shell_list bash zsh tcsh -do_updates path apsearch -dir_bin /Users/jazlynn/abin
-- good: .cshrc seems to contain 'source .tcshrc'
-- 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 4 dot files

source ~/.cshrc
source /Users/jazlynn/.tcshrc
if ( -f /Users/jazlynn/opt/anaconda3/etc/profile.d/conda.csh ) then
source /Users/jazlynn/opt/anaconda3/etc/profile.d/conda.csh
setenv CONDA_EXE /Users/jazlynn/opt/anaconda3/bin/conda
setenv _CONDA_ROOT /Users/jazlynn/opt/anaconda3
setenv _CONDA_EXE /Users/jazlynn/opt/anaconda3/bin/conda
setenv CONDA_PYTHON_EXE /Users/jazlynn/opt/anaconda3/bin/python
if ( ! 1 ) then
if ( /Users/jazlynn/opt/anaconda3/bin/conda ==  ) then
endif
if ( `alias conda` ==  ) then
alias conda
if ( 1 ) then
set _CONDA_PFX=`dirname "${_CONDA_EXE}"`
dirname /Users/jazlynn/opt/anaconda3/bin/conda
set _CONDA_PFX=`dirname "${_CONDA_PFX}"`
dirname /Users/jazlynn/opt/anaconda3/bin
alias conda source /Users/jazlynn/opt/anaconda3/etc/profile.d/conda.csh
unset _CONDA_PFX
else
setenv CONDA_SHLVL 0
if ( ! 0 ) then
set prompt=
endif
else
else
setenv PATH /Users/jazlynn/opt/anaconda3/bin:/Users/jazlynn/opt/anaconda3/condabin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/jazlynn/fsl/share/fsl/bin:/Users/jazlynn/fsl/share/fsl/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Apple/usr/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:/opt/homebrew/opt/python/libexec/bin:/Users/jazlynn/abin:/opt/homebrew/opt/python/libexec/bin:/Users/jazlynn/abin:/Users/jazlynn/abin
if ( 1 ) then
if (  !=  ) then
endif
setenv R_LIBS /Users/jazlynn/sw/R-4.3.1
setenv R_LIBS /Users/jazlynn/sw/R-4.3.1
setenv R_LIBS /Users/jazlynn/sw/R-4.3.1
setenv R_LIBS /Users/jazlynn/sw/R-4.3.1
if ( arm64 == x86_64 ) then
set package = macos_13_ARM_clang
endif
build_afni.py -build_root /Users/jazlynn/afni_build -package macos_13_ARM_clang

-- current AFNI: AFNI_24.2.03, anyos_text, Aug 20 2024
-- cleaning old build root dir, /Users/jazlynn/afni_build
-- backing up dir build_src
-- preparing build_root dir, /Users/jazlynn/afni_build
-- have default git tag LAST_TAG, will checkout AFNI_24.2.03
-- checking out git tag AFNI_24.2.03
-- using repo branch (detached), tag AFNI_24.2.03
-- removing old atlas dir, prev/afni_atlases_dist
-- moving old atlas dir afni_atlases_dist to prev/afni_atlases_dist
-- downloading AFNI atlas package, afni_atlases_dist.tgz
-- unpacking atlas package, afni_atlases_dist
-- removing old NiiVue backup, prev/niivue_afni.umd.js
-- moving old niivue niivue_afni.umd.js to prev/niivue_afni.umd.js
-- downloading NiiVue, niivue_afni.umd.js

-- preparing to run 'make' build of package macos_13_ARM_clang
-- copying README files
-- copying other_builds/Makefile.macos_13_ARM_clang to Makefile
-- building make target 'itall'

-- consider monitoring the build in a separate window with:
       cd /Users/jazlynn
       tail -f /Users/jazlynn/afni_build/build_src/log_make.txt
       # use ctrl-c to terminate 'tail' command (not the build)
++ building (please be patient)...
** error: failed run_cmd: make AFNI_WHOMADEIT=build itall >& log_make.txt
-- status: building FAILURE
   see 'make' log file /Users/jazlynn/afni_build/build_src/log_make.txt
** error: tail from log_make.txt:
   --------------------------------------------------
   |                  ^~~~~~~~~~~
   (cd leej3; \
   /opt/homebrew/bin/gcc-13 -arch arm64 -DDARWIN -DARM_M1 -O1 -m64 -Wall -Wno-deprecated-declarations -Wcomment -Wformat -DUSE_TRACING -DHAVE_XDBE -DDONT_USE_MCW_MALLOC  -c whats_my_exepath.c; \
   /bin/cp -f whats_my_exepath.o ..; \
   cd ..)
   /bin/rm -f afni
   /opt/homebrew/bin/gcc-13 -arch arm64 -DDARWIN -DARM_M1 -O1 -m64 -Wall -Wno-deprecated-declarations -Wcomment -Wformat -DUSE_TRACING -DHAVE_XDBE -DDONT_USE_MCW_MALLOC  -DWHATS_MY_EXEPATH -o afni afni.o afni_func.o afni_widg.o afni_warp.o afni_fimmer.o afni_slice_short.o afni_slice_float.o afni_filer.o afni_slice_byte.o  afni_slice_complex.o afni_pcor.o afni_pcor_float.o afni_transforms.o pbar.o afni_graph.o afni_plugin.o afni_cluster.o parser.o parser_int.o afni_plugout.o afni_fimfunc.o afni_setup.o afni_receive.o mcw_graf.o afni_splash.o afni_pplug_env.o afni_pplug_2dfunc.o afni_friends.o afni_ttren.o afni_pplug_1dfunc.o afni_driver.o afni_niml.o afni_sumafunc.o afni_slice_rgbyte.o afni_version.o afni_lock.o afni_vol2surf.o afni_pplug_instacorr.o afni_pplug_instacalc.o afni_pplug_tstat.o afni_whelp.o whats_my_exepath.o  -m64 -dynamic -L. -L/opt/homebrew/lib -L/opt/X11/lib -L/usr/lib  -lmrix -lcoxplot -lmri  libXmHTML.a libjpeg.a -lmri -lf2c -lXm -ljpeg -lXt -lXft -lfontconfig -lpng16 -liconv -lXmu -lXp -lXpm -lXext -lX11 -lz -lexpat  -lm -lc -lm -lc
   ld: file not found: libjpeg.a
   collect2: error: ld returned 1 exit status
   make: *** [afni] Error 1
   --------------------------------------------------

** warning: in conda environment
   CONDA_SHLVL = 0, CONDA_DEFAULT_ENV = base

-- shell/system command history is in:
      /Users/jazlynn/afni_build/hist_commands.txt

++ screen text history is in:
      /Users/jazlynn/afni_build/hist_messages.txt

rehash
setenv R_LIBS /Users/jazlynn/sw/R-4.3.1
echo export R_LIBS=/Users/jazlynn/sw/R-4.3.1
echo export R_LIBS=/Users/jazlynn/sw/R-4.3.1
echo setenv R_LIBS /Users/jazlynn/sw/R-4.3.1
mkdir -p /Users/jazlynn/sw/R-4.3.1
rPkgsInstall -pkgs ALL
tee out.rPkgsInstall.txt

** ERROR: Failed to load R_io.so

Running afni_system_check.py -check_all gives the output:

-------------------------------- general ---------------------------------
architecture:         64bit 
cpu type:             i386 (uname -m == x86_64)
system:               Darwin
release:              22.6.0
version:              Darwin Kernel Version 22.6.0: Wed Oct  4 21:26:43 PDT 2023; root:xnu-8796.141.3.701.17~4/RELEASE_ARM64_T8112
distribution:         10.16
number of CPUs:       8
apparent login shell: zsh
shell RC file:        .zshrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni           :
                     : 
AFNI_version.txt     : AFNI_24.2.03, anyos_text, Aug 20 2024, local
which python         : /Users/jazlynn/opt/anaconda3/bin/python
python version       : 3.9.13
which R              : /usr/local/bin/R
R version            : R version 4.3.1 (aarch64-apple-darwin20)

instances of various programs found in PATH:
    afni    : 0 
    R       : 1   (/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/bin/R)
    python  : 2 
      /Users/jazlynn/opt/anaconda3/bin/python3.9
      /opt/homebrew/Cellar/python@3.12/3.12.5/Frameworks/Python.framework/Versions/3.12/bin/python3.12
    python2 : 0 
    python3 : 3 
      /Users/jazlynn/opt/anaconda3/bin/python3.9
      /opt/homebrew/Cellar/python@3.12/3.12.5/Frameworks/Python.framework/Versions/3.12/bin/python3.12
      /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      : 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
        

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

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

++ module loaded: matplotlib.pyplot
   module file : /Users/jazlynn/opt/anaconda3/lib/python3.9/site-packages/matplotlib/pyplot.py
   matplotlib version : 3.6.3

++ module loaded: flask
   module file : /Users/jazlynn/opt/anaconda3/lib/python3.9/site-packages/flask/__init__.py
   flask version : 1.1.2

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

-------------------------------- env vars --------------------------------
PATH                       = /Users/jazlynn/opt/anaconda3/bin:/Users/jazlynn/opt/anaconda3/condabin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/jazlynn/fsl/share/fsl/bin:/Users/jazlynn/fsl/share/fsl/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Apple/usr/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:/opt/homebrew/opt/python/libexec/bin:/Users/jazlynn/abin:/opt/homebrew/opt/python/libexec/bin

PYTHONPATH (sub-shell) = 
R_LIBS                     = /Users/jazlynn/sw/R-4.3.1
LD_LIBRARY_PATH (sub-shell) = 
DYLD_LIBRARY_PATH (sub-shell) = 
DYLD_FALLBACK_LIBRARY_PATH (sub-shell) = 
CONDA_SHLVL                = 1
CONDA_DEFAULT_ENV          = base
CC (sub-shell) = 

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

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

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

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

   -- good: .cshrc seems to contain 'source .tcshrc'
   -- 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 : 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.3.18


=========================  summary, please fix:  =========================
*  CPU differs between python and uname?
*  just be aware: login shell 'zsh', but our code examples use 'tcsh'
*  missing program: afni
*  failure under initial "AFNI and related program tests"
*  AFNI programs show FAILURE
*  missing R packages (see rPkgsInstall)
*  please run: cp /Users/jazlynn/abin/AFNI.afnirc ~/.afnirc
*  please run: "suma -update_env" for .sumarc
*  please run: apsearch -update_all_afni_help
*  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

I saw other users with similar error messages and tried (in no particular order) the following but nothing worked:

  1. reinstalling x code developer tools
  2. installing gcc13 and glib via homebrew
  3. restarting and trying again
  4. checking my R version (it appears to be compatible with apple silicon)
  5. running build_afni.py -build_root /Users/jazlynn/afni_build -package macos_13_ARM_clang

Really appreciate any and all help. Thank you!!

Hmmm - in this case it looks like your machine is reporting that it's an Intel-based Mac:
cpu type: i386 (x86_64).

So it's possible that your computer is not an M2... or also possible that your terminal program has a checkbox asking it to open the terminal or Quartz in Rosetta - worth checking the screenshot below:

Would you mind checking your "About this Mac" under the apple menu and reporting what is listed there and also verifying that this checkbox on your terminal program is not checked?

Here's the screenshot. The rosetta setting isnt checked for xquartz either, if that matters

Intriguing!

Two more commands since you have anaconda installed...

First:

conda info

Second:

conda deactivate
uname -a

If the second set ( condo deactivate) returns an arm64 reponse, then try to re-run the afni_build scripts.

Thanks for your help!

I reran the last build step from the quick installation tutorial and it seems like the installation worked properly. However, when i run 'afni' in the terminal, XQuartz opens the GUI but loads only partially (ie. just a grey box appears without the usual buttons) even after I added the export DYLD_LIBRARY_PATH=/opt/X11/lib/flat_namespace line to my .zshrc file since I am using the zsh terminal. The warning to add that line no longer shows up but the GUI still does not load.

Fortunately though, the other commands in afni that do not use the GUI seem to be working. Is there a way to resolve this easily? I'm ok not having access to the GUI as my other linux machine has it working and I'm using this mac for more of the heavier batch processing rather than visualisation.

Hello,

Ok so the issue seems to be that you have the Intel version of Anaconda installed instead of the arm64 version (they had a strange way of autodetecting platform architectures for a while on their website). You'll notice the line
platform : osx-64
instead of
platform : osx-arm64.

So if you deactivate Conda and then run the afni install scripts, that should make things work. I would also recommend just removing Anaconda and installing the arm64 version for many benefits of speed!

The AFNI GUI not loading is interesting, post a screenshot if it persists.

Did you reboot after installing XQuartz? Are you seeing any errors in terminal after you try to launch AFNI?