carlosknows
carlosknows

Reputation: 21

zsh does not find 'conda'

Every time I try to use conda in my terminal I get this error:

zsh: correct 'conda' to '.conda' [nyae]?

I have added export PATH=$PATH:$HOME/anaconda/bin to my .zshrc and to my .bash_profile files.

Now, if I run source ~/.bash_profile it works, but I have to run this command every time I open a new window. Is there a way to fix this?

Upvotes: 2

Views: 440

Answers (2)

amirhe
amirhe

Reputation: 2341

In case you are working with function, it might be an issue with the your naming convention, try to name it with different names so it doesn't face collision with conda itself.

Also you can always use conda init $SHELL e.g. conda init zsh to reinitialize the conda env setup

function init {
    # 🌟 If the following line set to conda, it will face the same issue
    # 🌟 that's why I changed it to -conda
    if [ "$1" = "-conda" ]; then
        # 🌟 `conda init zsh` will re-initializing the following sections
        # >>> conda initialize >>>
        # !! Contents within this block are managed by 'conda init' !!
        __conda_setup="$('/Users/mu/miniconda/bin/conda' 'shell.zsh' 'hook' 2>/dev/null)"
        if [ $? -eq 0 ]; then
            eval "$__conda_setup"
        else
            if [ -f "/Users/mu/miniconda/etc/profile.d/conda.sh" ]; then
                . "/Users/mu/miniconda/etc/profile.d/conda.sh" # commented out by conda initialize
            else
                export PATH="/Users/mu/miniconda/bin:$PATH" # commented out by conda initialize
            fi
        fi
        unset __conda_setup
        # <<< conda initialize <<<

        conda activate ${2:-base} # initialize the conda env at the same time
  fi
}

Upvotes: 0

Willy Chen
Willy Chen

Reputation: 31

I got the same problem, so I copy the coda initialize code from my .bashrc to .zshrc and it worked.

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

Upvotes: 1

Related Questions