Search code examples
shellubuntuanacondacondatcsh

activating conda fails (sourcing ~/.bashrc)


I freshly installed Anaconda (Anaconda3-2019.07-Linux-x86_64) on "Ubuntu 14.04.5 LTS", but activating the installation fails with:

source ~/.bashrc returns Illegal variable name.

cat ~/.bashrc:

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/scientia/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/scientia/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/home/scientia/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/home/scientia/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

The first line seems to be the reason for that: __conda_setup="$('/home/scientia/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"


Solution

  • As you've found, the .bashrc initialization is bash-specific. However, Conda does also support initialization for csh/tcsh. Simply run

    /home/scientia/anaconda3/bin/conda init tcsh
    

    then restart your tcsh session and now Conda should be properly configured. You can run the above with a verbose flag -v if you want to see what it adds to .tcshrc.