AFNI install issues on M1 with R-4.2.3

Dear AFNI oracles,

I have been trying to install AFNI on a Mac M1 computer (Ventura 13.2.1), and still have some errors I don't manage to overcome. As suggested here in the forum, I used 'macos_13_ARM_clang' for the build.
This is the output of afni_system_check:

-------------------------------- general ---------------------------------
architecture:         64bit 
cpu type:             arm
system:               Darwin
release:              22.3.0
version:              Darwin Kernel Version 22.3.0: Mon Jan 30 20:38:37 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6000
distribution:         13.2.1
number of CPUs:       20
apparent login shell: zsh
shell RC file:        .zshrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni           : /Users/ramotlab/abin/afni
afni version         : Precompiled binary macos_13_ARM_clang: Aug 29 2023 
                     : AFNI_23.2.08 'Marcus Didius Severus Julianus'
AFNI_version.txt     : AFNI_23.2.08, macos_13_ARM_clang, Aug 29 2023, build
which python         : /opt/homebrew/opt/python/libexec/bin/python
python version       : 3.11.5
which R              : /usr/local/bin/R
R version            : R version 4.2.3 (2023-03-15) -- "Shortstop Beagle"

instances of various programs found in PATH:
    afni    : 1   (/Users/ramotlab/abin/afni)
    R       : 1   (/Library/Frameworks/R.framework/Versions/4.2/Resources/bin/R)
    python  : 1   (/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/bin/python3.11)
    python2 : 0 
    python3 : 2 
      /opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/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                : FAILURE
        Error in dyn.load(ll) : 
          unable to load shared object '/Users/ramotlab/abin/R_io.so':
          dlopen(/Users/ramotlab/abin/R_io.so, 0x0006): symbol not found in flat namespace '_EDIT_floatize_dataset'
        Calls: source ... withVisible -> eval -> eval -> set_R_io -> dyn.load
        Execution halted

------------------------ 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 : success

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

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

++ module loaded: matplotlib.pyplot
   module file : /opt/homebrew/lib/python3.11/site-packages/matplotlib/pyplot.py
   matplotlib version : 3.7.1

-------------------------------- env vars --------------------------------
PATH = /opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/opt/homebrew/bin:/opt/homebrew/opt/python/libexec/bin:/Library/Frameworks/R.framework/Resources:/usr/local/gfortran/bin:/Users/ramotlab/abin:/usr/local/opt/python/libexec/bin

PYTHONPATH = 
R_LIBS = /Users/ramotlab/sw/R-4.2.3

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                   : 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/ramotlab/abin

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

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

++ 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:/opt/X11/lib/flat_namespace:/opt/X11/lib/flat_namespace:/opt/X11/lib/flat_namespace:/opt/X11/lib/flat_namespace:/opt/X11/lib/flat_namespace:/opt/X11/lib/flat_namespace

=========================  summary, please fix:  =========================
*  just be aware: login shell 'zsh', but our code examples use 'tcsh'
*  AFNI programs show FAILURE
*  insufficient data for AFNI bootcamp
   (see "Prepare for Bootcamp" on install pages)
*  consider installing gcc under homebrew
*  consider installing glib under homebrew

Thanks for the help!
Meytal

Hello,

I've seen this error if you install R 4.2.x after you build AFNI. When you do the build_afni.py process, it links against the currently installed R version. Can you try installing R via CRAN? And not through a package manager just in case.

Also possible that you might have R_LIBS set strangely (I don't have it set at all) so perhaps that could be causing some issues.

-Peter

Thank you for the suggestions! I re-downloaded the latest R version from CRAN (version 4.3.1)
Should I rerun build_afni.py? what command should I use (I have the '13 arm clang')?

The R_LIBS from my .zshrc file are as follows:

export R_LIBS=$HOME/sw/R-4.2.3 

I tried erasing this completely (especially now that I updated the version), but still the same error. Should I reset it to something else?

I additionally tried to find the file that the error referred to (R_io.so) in my computer, and found it in the following locations:

/System/Volumes/Data/Users/ramotlab/abin/R_io.so
/System/Volumes/Data/Users/ramotlab/afni/build/build_src/macos_13_ARM_clang/R_io.so
/System/Volumes/Data/Users/ramotlab/afni/build/build_src/R_io.so
/System/Volumes/Data/Users/ramotlab/afni/build/prev.build_src/macos_13_ARM_clang/R_io.so
/System/Volumes/Data/Users/ramotlab/afni/build/prev.build_src/R_io.so

so it does seem to appear in the right folder (and in some other folders), but still the issue persists.

Thank you again for your help!
Meytal

Hi Meytal,

To be sure, does "R --version" show 4.3.1 now?

Yes, please rerun build_afni.py. You could cheat and just build a new R_io.so library, but it is probably safer to just build the whole package:

build_afni.py -build_root $HOME/afni_build -package macos_13_ARM_clang

Note that once the new build_afni.py is installed (which might not be this time), it will automatically back up and install the new binaries, unless you tell it otherwise.

Also, now that you have R-4.3.1, you will probably need to set R_LIBS to $HOME/sw/R-4.3.1 and (make that directory and) run rPkgsInstall -pkgs ALL again. But that can wait. You should be able to run 3dMVM -help before worrying about the R libraries.

  • rick

Hi Rick,

I tried to follow your suggestions, but still the problem persists...
I took the following steps:

  1. R --version shows 4.3.1
  2. I ran the 'build_afni.py' command again. and still the same error in the afni_system_check (restart didn't help convince it otherwise):
-------------------------------- general ---------------------------------                                                                            
architecture:         64bit                                                                                                                           
cpu type:             arm                                                                                                                             
system:               Darwin                                                                                                                          
release:              22.3.0                                                                                                                          
version:              Darwin Kernel Version 22.3.0: Mon Jan 30 20:38:37 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6000                            
distribution:         13.2.1                                                                                                                          
number of CPUs:       20                                                                                                                              
apparent login shell: zsh                                                                                                                             
shell RC file:        .zshrc (exists)                                                                                                                 

--------------------- AFNI and related program tests ---------------------                                                                            
which afni           : /Users/ramotlab/abin/afni                                                                                                      
afni version         : Precompiled binary macos_13_ARM_clang: Aug 29 2023                                                                             
                     : AFNI_23.2.08 'Marcus Didius Severus Julianus'                                                                                  
AFNI_version.txt     : AFNI_23.2.08, macos_13_ARM_clang, Aug 29 2023, build                                                                           
which python         : /opt/homebrew/opt/python/libexec/bin/python                                                                                    
python version       : 3.11.5                                                                                                                         
which R              : /usr/local/bin/R                                                                                                               
R version            : R version 4.3.1 (2023-06-16) -- "Beagle Scouts"                                                                                

instances of various programs found in PATH:                                                                                                          
    afni    : 1   (/Users/ramotlab/abin/afni)                                                                                                         
    R       : 1   (/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/bin/R)                                                                
    python  : 1   (/opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/bin/python3.11)                                  
    python2 : 0                                                                                                                                       
    python3 : 2                                                                                                                                       
      /opt/homebrew/Cellar/python@3.11/3.11.5/Frameworks/Python.framework/Versions/3.11/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                : FAILURE
        Error in dyn.load(ll) : 
          unable to load shared object '/Users/ramotlab/abin/R_io.so':
          dlopen(/Users/ramotlab/abin/R_io.so, 0x0006): tried: '/Users/ramotlab/abin/R_io.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/ramotlab/abin/R_io.so' (no such file), '/Users/ramotlab/abin/R_io.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))
        Calls: source ... withVisible -> eval -> eval -> set_R_io -> dyn.load
        Execution halted

------------------------ 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 : success

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

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

++ module loaded: matplotlib.pyplot
   module file : /opt/homebrew/lib/python3.11/site-packages/matplotlib/pyplot.py
   matplotlib version : 3.7.1

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

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

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

++ 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:/opt/X11/lib/flat_namespace:/opt/X11/lib/flat_namespace:/opt/X11/lib/flat_namespace:/opt/X11/lib/flat_namespace:/opt/X11/lib/flat_namespace:/opt/X11/lib/flat_namespace

=========================  summary, please fix:  =========================
*  just be aware: login shell 'zsh', but our code examples use 'tcsh'
*  AFNI programs show FAILURE
*  insufficient data for AFNI bootcamp
   (see "Prepare for Bootcamp" on install pages)
*  consider installing gcc under homebrew
*  consider installing glib under homebrew
  1. I manually set the R_LIBS to be $HOME/sw/R-4.3.1 in the .zshrc file, and manually added this folder with mkdir.

  2. When I tried to run rPkgsInstall again I got this error (similar to the check afni error):

updating R_LD_LIBRARY_PATH ...

oo Warning: 
   Failed to load R_io.so with this error message:

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

What seems to be the problem?

Thank you so much for the help,
Meytal

Hi Meytal,

I will send you a private message. It would be nice took look at the afni_build/build_src/log_make.txt file, but it is long and we might not want to paste the entire thing here.

Thanks,

  • rick

Thank you! That would be great

Sorry Meytal, I was sure that I had already written you! But apparently not...

Note that the afni server (afni.nimh.nih.gov) is still down, but git access via github.com is all that is needed to do a current build (if you have an afni_atlases_dist directory).

Thanks for the ping!

  • rick

HI Meytal,

Thank you for the log_make.txt file. It looks like everything went well in there.

So there is something odd going on here. The error you posted above is complaining about R_io.so being for an Intel architecture. Yet your AFNI version shows ARM, and the log_make.txt file shows an ARM build. So how is it that ~/abin/R_io.so is x86_64?

To be sure, what is the output from:

which afni
cd ~/abin
ls -l afni R_io.so
file afni R_io.so

Thanks,

  • rick

Hi Rick,

Here is the output I got:

/Users/ramotlab/abin/afni
-rwxr-xr-x  1 ramotlab  staff    53952 Aug 29 14:49 R_io.so
-rwxr-xr-x  1 ramotlab  staff  9959441 Aug 29 14:45 afni
afni:    Mach-O 64-bit executable arm64
R_io.so: Mach-O 64-bit dynamically linked shared library x86_64

That shows the problem, but the files even have basically the same time stamp.

If it is okay, please run the same commands form the bulid_src directory made by build_afni.py. We should be positive of what is currently being compiled. Hopefully you just need to sync the bulid results, but we'll see.

Thanks,

  • rick

I reran these commands while being in the build_src directory, and got basically the same output:

/Users/ramotlab/abin/afni
-rwxr-xr-x  1 ramotlab  staff    53952 Aug 29 14:49 R_io.so
-rwxr-xr-x  1 ramotlab  staff  9959441 Aug 29 14:45 afni
afni:    Mach-O 64-bit executable arm64
R_io.so: Mach-O 64-bit dynamically linked shared library x86_64

This seems conceivable, but one of those commands is cd ~/abin, and I just want to be 100% sure that you are not in the abin when running the 'file' commands.

To be positive, would you verify that the output is from something like:

cd afni_build/afni_src/macos_13_ARM_clang
pwd
ls -l afni R_io.so
file afni R_io.so

Is that correct?

I just want to be sure, thanks.

  • rick

Dear Rick,

Indeed I cd'ed to abin folder before running the command. Now I ran the following:

cd afni_build/build_src/macos_13_ARM_clang
pwd
ls -l afni R_io.so
file afni R_io.so

and got the following output:

/Users/ramotlab/afni_build/build_src/macos_13_ARM_clang
-rwxr-xr-x  1 ramotlab  staff  4146004 Sep 11 09:14 R_io.so
-rwxr-xr-x  1 ramotlab  staff  9959441 Sep 11 09:10 afni
afni:    Mach-O 64-bit executable arm64
R_io.so: Mach-O 64-bit dynamically linked shared library arm64

It is slightly different from before. What should I do to clear up the mess?

Thanks again!
Meytal

Yay! This looks good, as both files are of cpu-type arm64. So all you need to do is actually sync the build results into your home abin directory. The current abin is a mix of cpu types for some reason. Please run this command:

rsync -av ~/afni_build/build_src/macos_13_ARM_clang/ ~/abin/

Next time you run build_afni.py, depending on which versionn you are actually running, it will either tell you rsync the build results as above (the pre-Sept 8 version), or it will automatically back up and install the results for you (the post-Sept 8 version, at least AFNI_23.2.09).

Anyway, please run the rsync command and show us the output of

afni_system_check.py -check_all

again.

Thanks,

  • rick
1 Like

Yay no errors now! I had to reinstall all the R packages, but now the the afni check seems find:

=========================  summary, please fix:  =========================
*  just be aware: login shell 'zsh', but our code examples use 'tcsh'
*  insufficient data for AFNI bootcamp
   (see "Prepare for Bootcamp" on install pages)

Thanks for your help and patience!!

That is great, I'm glad it's all set up!

  • rick
1 Like