External Email - Use Caution
In a HPC cluster where freesurfer is loaded ad hoc as a module, running module avail results in the following warning:
/path/to/anaconda3-2021.11/bin/mpicc: line 285: x86_64-conda_cos6-linux-gnu-cc: command not found ERROR: Environment variable FREESURFER_HOME must be defined prior to sourcing Freesurfer. /path/to/anaconda3-2021.11/bin/mpicc: line 285: x86_64-conda_cos6-linux-gnu-cc: command not found ERROR: Environment variable FREESURFER_HOME must be defined prior to sourcing Freesurfer.
I don't think ts related but here is my .bashrc file:
conda initialize >>>
!! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/path/to/anaconda3-2021.11/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/path/to/anaconda3-2021.11/etc/profile.d/conda.sh" ]; then
. "/path/to/anaconda3-2021.11/etc/profile.d/conda.sh"
else
export PATH="/path/to/anaconda3-2021.11/bin:$PATH"
fi
fi
unset __conda_setup
The modulefile for Freesurfer contains:
module-whatis "adds freesurfer to your environment variables"
set root /path/to/freesurfer
setenv "FREESURFER_HOME" "/path/to/freesurfer"
setenv "SUBJECTS_DIR" "/path/to/freesurfer/subjects"
prepend-path PATH $root/bin
if { [ module-info mode load ] } {
system "source /path/to/freesurfer/SetUpFreeSurfer.sh"
}
I see that SetUpFreeSurfer.sh has this:
# Call configuration script:
source $FREESURFER_HOME/FreeSurferEnv.sh
After running module unload freesurfer several directories remain in $PATH:
echo $PATH /path/to/freesurfer/fsfast/bin:/path/to/freesurfer/tktools:/path/to/freesurfer/mni/bin:/path/to/freesurfer/fsfast/bin:/path/to/freesurfer/tktools:/path/to/freesurfer/mni/bin
So $FREESURFER_HOME and $SUBJECTS_DIR are being unset but all of the other env vars are not. Is there a way to unset the vars from FreeSurferEnv.sh? A thread on SO https://secure-web.cisco.com/1oVSBML06vH3hcXfhl4P1X2gg9xkRWHiWCsxRgOqnwVIMAO0DHimnWQfzJWx6WlphtBtrQvalCpHAokzy0D1ZAnF__WxdjRxngkjCs3rkh5cFohb1peqFGvLasAjXhk_DlqYviU5CpAYc75fxNHaVogprkgYWCU-gUkcETmX13-ecr4Wz4S0bl_tdPiCwsVtMXAva1o4MWKV5XoiHjxGpjY4HIRzMClKXBlnSXp1S_ZzLGE-ehKeLh4AjKfafeXztsZlOr5sXKmkKHSk2F28w1L_5QcKGrjBeQtQzbFJTxk6k0BDOGypRb-WSPz1tjzze/https%3A%2F%2Fstackoverflow.com%2Fquestions%2F69274347%2Foverwrite-and-restore-environment-variables-in-bash-with-environment-modules mentions using unsetenv but perhaps there's an elseif that can be added to the modulefile?
freesurfer@nmr.mgh.harvard.edu