AFNI Download on M1 (macOS Monterey)

Hi,

I am looking for some assistance on downloading AFNI on a new computer. It is one of the new Macs with the M1 processor. I read another discussion on the Message Board (topic: M1 processor compatibility?) and tried downloading with the use of a Rosetta terminal. However, I am still getting an error at the R step.

[Mollys-MBP:~] mollywilkinson% sudo rPkgsInstall -pkgs ALL
sudo: rPkgsInstall: command not found

This is the output for the system check:

[Mollys-MBP:~] mollywilkinson% afni_system_check.py -check_all
afni_system_check.py: Command not found.

Any assistance would be great! Thank you :slight_smile:

Hi,

Do you have admin access on your computer?
You can check with:


sudo ls

I am working on some better instructions for macOS 12.3.1 and greater including M1.
But there are no pre-compiled afni binaries for the M1 (or upcoming M2) as of yet.
Soon! Pre-compiled apple silicon (M1 etc) will be faster, but with rosetta 2, it is not that much slower.

If you do have admin access and macOS 12.3.1 or greater, you can try these instructions:
(these may work on macOS 11 and 13, but they have not been tested on those versions)
(these are designed for a brand new system, so you may already have some things installed)
(this assumes you have installed the rosetta 2 system, as you have)
Copy + paste these separately:


cd
/bin/bash -c "$(curl -fsSL [https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh](https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh))"


brew install python netpbm cmake
brew install --cask xquartz


curl -s -L -o R-3.6.3.nn.pkg "[https://cran.r-project.org/bin/macosx/el-capitan/base/R-3.6.3.nn.pkg](https://cran.r-project.org/bin/macosx/el-capitan/base/R-3.6.3.nn.pkg)"
sudo installer -pkg R-3.6.3.nn.pkg -target /
rm R-3.6.3.nn.pkg


curl -s -L -o gfortran-6.1.pkg "[https://cloud.r-project.org/bin/macosx/tools/gfortran-6.1.pkg](https://cloud.r-project.org/bin/macosx/tools/gfortran-6.1.pkg)"
sudo installer -pkg gfortran-6.1.pkg -target /
rm gfortran-6.1.pkg


touch ~/.zshrc
echo 'export PATH=$PATH:/usr/local/opt/python/libexec/bin' >> ~/.zshrc
echo 'export PATH=$PATH:/Library/Frameworks/R.framework/Resources' >> ~/.zshrc
echo 'export PATH=$PATH:/usr/local/gfortran/bin' >> ~/.zshrc
source ~/.zshrc


Rscript -e "install.packages(c('afex','phia','snow','nlme','lmerTest'),repos='[https://cloud.r-project.org](https://cloud.r-project.org)')"


curl -O https://afni.nimh.nih.gov/pub/dist/bin/misc/@update.afni.binaries
tcsh @update.afni.binaries -package macos_10.12_local -do_extras


afni_system_check.py -check_all

Thanks, Justin

Hi Justin,

Thanks! Very helpful. Yes, I do have admin access on my computer based on System Preferences.
All of the commands work great until the 5th code block. I ran everything in the Rosetta terminal. I’m not sure if this should be using zsh, which is the default on this new Mac, or bash. I have put the output below for both:

zsh output:

(base) mollywilkinson@Mollys-MacBook-Pro ~ % touch ~/.zshrc
echo ‘export PATH=$PATH:/usr/local/opt/python/libexec/bin’ >> ~/.zshrc
echo ‘export PATH=$PATH:/Library/Frameworks/R.framework/Resources’ >> ~/.zshrc
echo ‘export PATH=$PATH:/usr/local/gfortran/bin’ >> ~/.zshrc
source ~/.zshrc
touch: /Users/mollywilkinson/.zshrc: Permission denied
zsh: permission denied: /Users/mollywilkinson/.zshrc
zsh: permission denied: /Users/mollywilkinson/.zshrc
zsh: permission denied: /Users/mollywilkinson/.zshrc

bash output:

bash-3.2$ touch ~/.zshrc
touch: /Users/mollywilkinson/.zshrc: Permission denied
bash-3.2$ echo ‘export PATH=$PATH:/usr/local/opt/python/libexec/bin’ >> ~/.zshrc
bash: /Users/mollywilkinson/.zshrc: Permission denied
bash-3.2$ echo ‘export PATH=$PATH:/Library/Frameworks/R.framework/Resources’ >> ~/.zshrc
bash: /Users/mollywilkinson/.zshrc: Permission denied
bash-3.2$ echo ‘export PATH=$PATH:/usr/local/gfortran/bin’ >> ~/.zshrc
bash: /Users/mollywilkinson/.zshrc: Permission denied
bash-3.2$ source ~/.zshrc

hmmm.
Strange you don’t have permissions for that file (.zshrc).

can you run?:


ls -l ~/.zshrc 

The output should look something like this:


-rw-r--r--  1 discoraj  staff  993 May 13 12:41 /Users/discoraj/.zshrc

Your username should be the owner (where it says discoraj for mine).
Did someone else create that file?

Can you run:?


cat ~/.zshrc 

And post the output.
Let’s see if there is anything funky in there.

thanks, Justin

Hi Justin,

Thanks for your reply.

Here is the output of the first command:

[Mollys-MacBook-Pro:~] mollywilkinson% ls -l ~/.zshrc
-rw-r–r-- 1 root staff 446 Jun 8 12:20 /Users/mollywilkinson/.zshrc

This is my personal computer, so no one else has created any files on here.

Here is the output of the second:

cat ~/.zshrc

>>> conda initialize >>>

!! Contents within this block are managed by ‘conda init’ !!

__conda_setup=“$(‘/opt/anaconda3/bin/conda’ ‘shell.zsh’ ‘hook’ 2> /dev/null)”
if [ $? -eq 0 ]; then
eval “$__conda_setup”
else
if [ -f “/opt/anaconda3/etc/profile.d/conda.sh” ]; then
. “/opt/anaconda3/etc/profile.d/conda.sh”
else
export PATH=“/opt/anaconda3/bin:$PATH”
fi
fi
unset __conda_setup

<<< conda initialize <<<

Hi,

Ok. seems like .zshrc was created by root or using “sudo”.
you can reclaim ownership with:


sudo chown mollywilkinson ~/.zshrc

Then continue to run the original instructions.
HOWEVER…
The M1 version may have some different path settings, so we will have to deal with that when you get to it.
Unfortunately I don’t have my M1 at the moment, but I think we can figure it out.
Sorry for all the trouble. We are working to make this easier soon.

thanks, Justin

Perfect! That worked to get past those commands.

And yes you’re right, there are probably different path settings. When I get to the last line in that “touch zshrc” block I get this output:

[Mollys-MacBook-Pro:~] mollywilkinson% source ~/.zshrc
Illegal variable name.

ok.
post the output of this again:


cat ~/.zshrc

[Mollys-MacBook-Pro:~] mollywilkinson% cat ~/.zshrc

>>> conda initialize >>>

!! Contents within this block are managed by ‘conda init’ !!

__conda_setup=“$(‘/opt/anaconda3/bin/conda’ ‘shell.zsh’ ‘hook’ 2> /dev/null)”
if [ $? -eq 0 ]; then
eval “$__conda_setup”
else
if [ -f “/opt/anaconda3/etc/profile.d/conda.sh” ]; then
. “/opt/anaconda3/etc/profile.d/conda.sh”
else
export PATH=“/opt/anaconda3/bin:$PATH”
fi
fi
unset __conda_setup

<<< conda initialize <<<

export PATH=$PATH:/usr/local/opt/python/libexec/bin
export PATH=$PATH:/Library/Frameworks/R.framework/Resources
export PATH=$PATH:/usr/local/gfortran/bin
export PATH=$PATH:/usr/local/opt/python/libexec/bin
export PATH=$PATH:/Library/Frameworks/R.framework/Resources
export PATH=$PATH:/usr/local/gfortran/bin

You should be able to delete the last 3 lines as they are repeats.
I don’t see any illegal names.
Quit the terminal if you aren’t using it and restart your machine.
Then just continue with the next steps (Rscript, curl etc)

Awesome! Thank you.

The Rscript seemed to have worked.

Unfortunately I’m getting another error:

[Mollys-MacBook-Pro:~] mollywilkinson% curl -O [afni.nimh.nih.gov]
curl: No match.

I tried putting the website in single quotes, as my Google search suggested but that resulted in:
[Mollys-MacBook-Pro:~] mollywilkinson% curl -O ‘afni.nimh.nih.gov
curl: Remote file name has no length!

I really appreciate your help on all this!

sorry, artifact of the message board messes up the web addresses if I don’t pay attention…
try this


curl -O [https://afni.nimh.nih.gov/pub/dist/bin/misc/@update.afni.binaries](https://afni.nimh.nih.gov/pub/dist/bin/misc/@update.afni.binaries)

Ok, hopefully last question…
Permission denied in this last step? I can see the abin folder in my home directory (mollywilkinson).

[Mollys-MacBook-Pro:~] mollywilkinson% tcsh @update.afni.binaries -package macos_10.12_local -do_extras
– running @update.afni.binaries version 3.20, May 3, 2022
– no current AFNI package found in path…
– install dir: using default ~/abin
– any downloads will be from https://afni.nimh.nih.gov via curl -O -f

– attempting to install package macos_10.12_local under
install dir: /Users/mollywilkinson/abin…
– have install dir
deleting old temporary directory…
++ working in new temp dir, .tmp.install
++ getting install prog: curl -O -f bin/misc/@update.afni.binaries
curl -O -f 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 49912 100 49912 0 0 74501 0 --:–:-- --:–:-- --:–:-- 74830
– fixing lost permissions on @update.afni.binaries
@update.afni.binaries is current, continuing with this version…
++ downloading test file: curl -O -f macos_10.12_local/afni …
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 11.7M 100 11.7M 0 0 1902k 0 0:00:06 0:00:06 --:–:-- 2366k

++ update needed, installing…

++ downloading full package: curl -O -f macos_10.12_local.tgz …
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 966M 100 966M 0 0 4093k 0 0:04:01 0:04:01 --:–:-- 3727k
++ extracting package macos_10.12_local.tgz…
++ backing up current binaries to auto_backup.macos_10.12_local
deleting previous backup directory, auto_backup.macos_10.12_local …
++ installing new binaries…
++ adding /Users/mollywilkinson/abin to path in /Users/mollywilkinson/.tcshrc …
/Users/mollywilkinson/.tcshrc: Permission denied.

Do the same chown for the other .files.


sudo chown mollywilkinson ~/.bashrc
sudo chown mollywilkinson ~/.cshrc
sudo chown mollywilkinson ~/.tcshrc

Just run the tcsh @update.afni.binaries -package macos_10.12_local -do_extras again.
If there are any other files giving you permissions problems, check the owner with the ls -al.
Then fix the ownership as above.
You may want to try and figure out why that is happening/happened.
Let me know how it goes.

Thanks, Justin

Great! That allowed me to run that tcsh @update line.

But now when I check all:

[Mollys-MacBook-Pro:~] mollywilkinson% afni_system_check.py -check_all
afni_system_check.py: Command not found.

hmm.

quit and restart your terminal. (restarting the whole machine would be better)
Then try again.
If you get the same thing, try this:


echo 'export PATH=$PATH:/Users/mollywilkinson/abin' >> ~/.zshrc 
source ~/.zshrc

This assumes you used the defaults for the afni installation.