R set-up AFNI error

Hi all,

I'm trying to run a 3dMVM script, but am getting the following error:

updating R_LD_LIBRARY_PATH ...

Error in library("afex") : there is no package called ‘afex’

Execution halted

The output to afni_system_check-py -check_all is below:

-------------------------------- general ---------------------------------
architecture:         64bit 
cpu type:             arm
system:               Darwin
release:              22.4.0
version:              Darwin Kernel Version 22.4.0: Mon Mar  6 21:01:02 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T8112
distribution:         13.3
number of CPUs:       8
apparent login shell: zsh
shell RC file:        .zshrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni           : /Users/jlaing2/abin/afni
afni version         : Precompiled binary macos_10.12_local: Aug  9 2023 
                     : AFNI_23.2.04 'Marcus Didius Severus Julianus'
AFNI_version.txt     : AFNI_23.2.04, macos_10.12_local, Aug 09 2023, official
which python         : /opt/homebrew/opt/python/libexec/bin/python
python version       : 3.11.4
which R              : /usr/local/bin/R
R version            : R version 3.6.3 (2020-02-29) -- "Holding the Windsock"

instances of various programs found in PATH:
    afni    : 1   (/Users/jlaing2/abin/afni)
    R       : 1   (/Library/Frameworks/R.framework/Versions/3.6/Resources/bin/R)
    python  : 1   (/opt/homebrew/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/bin/python3.11)
    python2 : 0 
    python3 : 1   (/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: metafor!
        

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.2

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

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)
   
   dot file test : want 1 modifications across 3 files:
   
      file             path  flatdir  apsearch        follower
      ---------------  ----  -------  --------        --------
      .cshrc           0     0        1               0     
      .tcshrc          0     0        0               1     
      .zshrc           0     0        0               0     
   
------------------------------ data checks -------------------------------
data dir : found AFNI_data6   under $HOME (471482M Avail)
           top history: ...3 [rickr]: renamed GroupAna_cases scripts and output
data dir : found AFNI_demos   under $HOME
           top history: ...ct 2020 [taylorp]: updated scripts under FATCAT_DEMO
data dir : found suma_demo    under $HOME
           top history: ...s_New/data/Build_tmp on Mon Mar  4 11:56:45 EST 2013
data dir : found afni_handouts under $HOME
atlas    : found TT_N27+tlrc  under /Users/jlaing2/abin

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


** no package manager found (okay for bootcamp)
++ 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 'zsh', but our code examples use 'tcsh'
*  missing R packages (see rPkgsInstall)
*  dot file test : want 1 modifications across 3 files:

rPkgsInstall -pkgs ALL provides the following output:

updating R_LD_LIBRARY_PATH ...
Warning: dependency ‘pbkrtest’ is not available
also installing the dependency ‘car’

Warning: unable to access index for repository http://cloud.r-project.org/bin/macosx/el-capitan/contrib/3.6:
  cannot open URL 'http://cloud.r-project.org/bin/macosx/el-capitan/contrib/3.6/PACKAGES'
installing the source packages ‘car’, ‘afex’, ‘phia’

trying URL 'http://cloud.r-project.org/src/contrib/car_3.1-2.tar.gz'
Content type 'application/x-gzip' length 579829 bytes (566 KB)
==================================================
downloaded 566 KB

trying URL 'http://cloud.r-project.org/src/contrib/afex_1.3-0.tar.gz'
Content type 'application/x-gzip' length 3567552 bytes (3.4 MB)
==================================================
downloaded 3.4 MB

trying URL 'http://cloud.r-project.org/src/contrib/phia_0.2-1.tar.gz'
Content type 'application/x-gzip' length 547339 bytes (534 KB)
==================================================
downloaded 534 KB

ERROR: dependency ‘pbkrtest’ is not available for package ‘car’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/car’
ERROR: dependencies ‘pbkrtest’, ‘car’ are not available for package ‘afex’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/afex’
ERROR: dependency ‘car’ is not available for package ‘phia’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/phia’

The downloaded source packages are in
	‘/private/var/folders/xc/1zz7s0bx3x96kn9knhnzcz4dnh7zwz/T/RtmpmQJ08x/downloaded_packages’

++ Note:  @ 12:26:21
   	This package has been installed on the computer: afex
	This package has been installed on the computer: phia
	This package has been installed on the computer: metafor

Warning messages:
1: package ‘metafor’ is not available (for R version 3.6.3) 
2: In install.packages(pkgs_miss, dep = NA, repos = site) :
  installation of package ‘car’ had non-zero exit status
3: In install.packages(pkgs_miss, dep = NA, repos = site) :
  installation of package ‘afex’ had non-zero exit status
4: In install.packages(pkgs_miss, dep = NA, repos = site) :
  installation of package ‘phia’ had non-zero exit status

Any help would be very appreciated!
Thank you,
Julia

Hi Julia,

You're running into an error because the version of R you have installed is now outdated. Since you're on an ARM Mac system, the recommendation is to install a new version of R (https://cran.r-project.org) and then use the build_afni.py tool.

You'll need to do a little bit of prep following the instructions in two parts:

  1. Admin Privileges
  2. User Privileges

The first one sets up all the dependencies that AFNI needs to compile, the second one gives instructions to do the actual compilation. In your case you'd be doing:
build_afni.py -build_root $HOME/afni/build -package macos_13_ARM_clang

Let us know if you get stuck on any part of the process.

-Peter

Thanks for your quick reply, Peter.

I'm getting an error here:

curl -O https://cran.r-project.org/bin/macosx/base/R-4.2.3.pkg
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0Warning: Failed to open the file R-4.2.3.pkg: Read-only file system
  0 88.6M    0 16384    0     0  10958      0  2:21:22  0:00:01  2:21:21 11010
curl: (23) Failure writing output to destination

Thank you again for your help!
Julia

Looks like you may not have permission to write to whatever directory you're currently in. Can you try in another directory?

I would also try either directly from the webpage or to use this link for the current version as of Aug 24, 2023.

curl -O https://cran.r-project.org/bin/macosx/big-sur-arm64/base/R-4.3.1-arm64.pkg

Thanks, Peter. That worked and now I've moved onto the User Privileges documentation.

I'm getting the following error after the -bindir $HOME/abin command:

:abin jlaing2$  -bindir $HOME/abin
-bash: -bindir: command not found

Thanks for your continued help!

Hello,

That -bindir option is part of the previous command, but it might be the default anyway.
What is the output of:

cat ~/abin/AFNI_version.txt

If that looks okay, note that the subsequent init_user_dotfiles.py also has a line continuation character that connects the next line with it (so -do_updates ... is part of the command).

  • rick

Thanks, Rick. Here's the output of

cat ~/abin/AFNI_version.txt
AFNI_23.2.08
anyos_text
Aug 22 2023
local

When I do the next command, ~/abin/init_user_dotfiles.py -shell_list bash zsh tcsh \ -do_updates path apsearch -dir_bin ~/abin

I get the following error:

env: python: No such file or directory

Thanks again for your help,
Julia

Hi Julia,

In the earlier system_check post, it shows a valid python. Did you reboot after finishing the admin steps? Either way, it might be enough to just start a new zsh, maybe by opening a new terminal. Open a new terminal window and try:

which python

If that works (shows a path to python), try the command again from the new terminal.

  • rick

Thanks, Rick. That command did show a path to python so I went ahead with that next command in a new terminal window, which appeared to work:

~ % ~/abin/init_user_dotfiles.py -shell_list bash zsh tcsh \              
        -do_updates path apsearch -dir_bin ~/abin

output:

-- 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 4 dot files

When I try the next command,

build_afni.py -build_root $HOME/afni/build -package macos_13_ARM_clang

I get this output/error:


-- current AFNI: AFNI_23.2.08, anyos_text, Aug 22 2023
-- cleaning old build root dir, /Users/jlaing2/afni/build
-- backing up dir build_src
-- preparing build_root dir, /Users/jlaing2/afni/build
-- have default git tag LAST_TAG, will checkout AFNI_23.2.08
-- checking out git tag AFNI_23.2.08
-- using repo branch (detached), tag AFNI_23.2.08
-- will reuse existing atlas directory, afni_atlases_dist

-- will run 'make' build of package macos_13_ARM_clang
-- copying other_builds/Makefile.macos_13_ARM_clang to Makefile
-- building make target 'itall'
++ building ...
   consider monitoring the build in a separate window with:
       cd /Users/jlaing2
       tail -f /Users/jlaing2/afni/build/build_src/log_make.txt
       # use ctrl-c to terminate 'tail' command (not the build)
** error: failed run_cmd: make AFNI_WHOMADEIT=build itall >& log_make.txt
** error: 
-- status: building FAILURE
   see 'make' log file /Users/jlaing2/afni/build/build_src/log_make.txt

       ------------------------------
       to possibly rsync atlases:
          rsync -av /Users/jlaing2/afni/build/afni_atlases_dist/ /Users/jlaing2/abin/
       
       ------------------------------
       shell/system command history is in:
          /Users/jlaing2/afni/build/hist_commands.txt
       ------------------------------
       screen text history is in:
          /Users/jlaing2/afni/build/hist_messages.txt

I did try to open up a new terminal window to run this latest command to see if that made a difference, but same error.

Thank you for your continued help! It's very much appreciated.

Julia

Hi Julia,

Would you please send me a private message, attaching that afni/build/build_src/log_make.txt file, along with the text output from:

~/abin/afni_system_check.py -check_all

I will ponder some ways to evaluate the current setup.
Thanks,

  • rick