Hi @esiesil, sorry about that. You’re running into a bit of workaround code I wrote. I’m guessing you did brew install gnu-sed at some point, and I didn’t think to consider that in my workaround!
Until we get a new release for you, you can run this (copy paste the whole thing) to get it working
cd /Users/s5110052/sct_5.4
patch <<EOF
From 6592dfc01cf7900dad33788ecabfdaf23b5f4338 Mon Sep 17 00:00:00 2001
From: Joshua Newton <joshuacwnewton@gmail.com>
Date: Wed, 17 Nov 2021 12:45:21 -0500
Subject: [PATCH] \`install_sct\`: Replace sed with \`perl -pi -e\`
---
install_sct | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
diff --git a/install_sct b/install_sct
index 205a1a20c..26fe7e7d9 100755
--- a/install_sct
+++ b/install_sct
@@ -325,17 +325,6 @@ if [ "\$(uname)" = "Darwin" ]; then
(command -v realpath >/dev/null) || realpath() {
python3 -c 'import sys, os; [print(os.path.realpath(f)) for f in sys.argv[1:]]' "\$@"
}
-
-
- # glue over the difference between how BSD and GNU sed work with -i
- # https://code-examples.net/en/q/56e314
- sed_i() {
- sed -i '' "\$@"
- }
-else
- sed_i() {
- sed -i "\$@"
- }
fi
# ======================================================================================================================
@@ -613,7 +602,7 @@ find "\$SCT_DIR/\$PYTHON_DIR" -type f -exec touch {} +
# * https://github.com/spinalcordtoolbox/spinalcordtoolbox/issues/3200
# this needs to be added very early in python's boot process
# so using sitecustomize.py or even just appending to the file are impossible.
-sed_i 's/^ENABLE_USER_SITE.*\$/ENABLE_USER_SITE = False/' "\$SCT_DIR/\$PYTHON_DIR/envs/venv_sct/lib/python"*"/site.py"
+perl -pi -e 's/^ENABLE_USER_SITE.*\$/ENABLE_USER_SITE = False/' "\$SCT_DIR/\$PYTHON_DIR/envs/venv_sct/lib/python"*"/site.py"
# activate miniconda
# shellcheck disable=SC1091
@@ -721,11 +710,11 @@ conda deactivate >/dev/null 2>&1
if [[ -e "\$RC_FILE_PATH" ]]; then
if grep "sct_env" "\$RC_FILE_PATH"; then
print info "In case an old version SCT is already installed (4.0.0-beta.1 or before), remove 'sct_env' declaration in RC file"
- sed_i '/sct_env/ s/^#*/#/' "\$RC_FILE_PATH"
+ perl -pi -e '/sct_env/ s/^#*/#/' "\$RC_FILE_PATH"
fi
if grep "^export MPLBACKEND=Agg" "\$RC_FILE_PATH"; then
print info "Commenting out 'export MPLBACKEND=Agg' from previous SCT installation"
- sed_i 's/^export MPLBACKEND=Agg/# The line below has been commented out by a more recent installation of SCT,\\
+ perl -pi -e 's/^export MPLBACKEND=Agg/# The line below has been commented out by a more recent installation of SCT,\\
# because export MPLBACKEND=Agg is no longer needed as of SCT v5.4.0\\
# export MPLBACKEND=Agg/' "\$RC_FILE_PATH"
fi
--
2.34.0
EOF
./install_sct
Based on the error message, my best guess is that some point in the past, ANTs was installed on your system using conda, and the corresponding conda environment was modified to add the ANTSPATH environment variable. But, I think there might be an issue with how this environment variable is being unset.
To verify that this is the problem, in a new terminal window, try deactivating the existing conda environment to see if you encounter the same error:
conda deactivate
If the same error occurs, you may want to double-check Line 2 of your /opt/anaconda2/etc/conda/deactivate.d/ants_env.sh script to make sure that ANTSPATH is being set correctly. (See also: this StackOverflow answer.)
Apart from that, as far as the SCT installation is concerned, can you make sure that any existing conda environments are deactivated before you start SCT’s install script?
Hi @joshuacwnewton, thanks for your help!
Sorry, but I haven’t been able to troubleshoot the issue. I’m not experienced with this, apologies.
I tried conda deactivate as suggested. No output comes up on the terminal. I proceeded to install spinal cord toolbox again but the same error persists:
$ conda deactivate
sed: can’t read s/^ENABLE_USER_SITE.*$/ENABLE_USER_SITE = False/: No such file or directory
Installation failed!
I’ve checked the ants_env.sh file, as per your recommendation. I have found I have many files (?) with this name (this is a shared computer, not sure who installed ANTS before). Three ants_env.sh are stored in the activate.d folder and the other three are in the deactivate.d folder. The paths for each of the three files in the deactivate folder are:
/opt/anaconda2/pkgs/ants-2.3.1-0/etc/conda/deactivate.d/ants_env.sh
/opt/anaconda3/pkgs/ants-2.3.1-0/etc/conda/deactivate.d/ants_env.sh
/opt/anaconda2/etc/conda/deactivate.d/ants_env.sh
When I type in the terminal which conda, I get: /opt/anaconda2/bin/conda
/opt/anaconda2/etc/conda/deactivate.d/ants_env.sh:
#!/bash/bin
unset ANTSPATH=/opt/anaconda2/bin/\n
In this deactivate.d folder, there are other files (deactivate_clang_osx-64.sh, deactivate_clangxx_osx-64.sh, deactivate-gfortran_osx-64.sh and java_home.sh)
Any ideas on how to proceed? Apologies once again for all this mess…
Thanks,
Eva
(The goal is to make your “ants_env.sh” scripts inside the “deactivate.d/” folders look similar to “Step 4.” from this guide, by excluding the “=” part.)
Once you make this change and save your files, then please run the suggestion from @nguenthe’s comment once more.