20

When I type which conda in terminal it returns somewhat unexpected result as below.

conda () {
        if [ "$#" -ge 1 ]
        then
                local cmd="$1" 
                shift
        else
                local cmd="" 
        fi
        case "$cmd" in
                (activate) _conda_activate "$@" ;;
                (deactivate) _conda_deactivate "$@" ;;
                (install | update | uninstall | remove) $_CONDA_EXE "$cmd" "$@"
                        _conda_reactivate ;;
                (*) $_CONDA_EXE "$cmd" "$@" ;;
        esac
}

I'm using pyenv in MAC.

I looked ~/.zshrc but found nothing special.

I expected which version I'm using to be printed, but I am getting some messages I cannot understand

Siong Thye Goh
  • 3,518
  • 10
  • 23
  • 31
임정섭
  • 347
  • 2
  • 9

2 Answers2

22

Executing which -p conda in your zsh, it will return the path instead of the script. For more information, read this answer.

Long
  • 1,482
  • 21
  • 33
4

Starting version 4.4, conda uses a wrapper shell function to capture commands and pass it to the executable. Not sure which version of conda you're using, and I'm more familiar of the Bash wrapper but it definitely looks like such function.

If you want to know the version, you should use conda --version.

Else, use conda or conda --help for more information on the CLI, or have a look to the official doc.

FabienP
  • 3,018
  • 1
  • 20
  • 25
  • my conda is 4.4.10 and I still want to use "which conda" to figure out am I using what conda env I am using. – 임정섭 May 21 '19 at 07:43
  • 1
    `which conda` will not give you the environnement you're using, but should give you the path to the conda executable. Can you try to upgrade your conda version (should be `conda update conda -n root` for 4.4). Usually there is a PS1 modifier to indicate that in your terminal, alternatively you can use `conda env list` for this. The environment with a star is the active one. – FabienP May 21 '19 at 08:57
  • 2
    @임정섭 There is [another question that answers how to determine the active env](https://stackoverflow.com/questions/36539623/how-do-i-find-the-name-of-the-conda-environment-in-which-my-code-is-running). To be fair, your question only asked for version, not environment, and Fabien has answered that very clearly. Please also see [What should I do when someone answers my question?](https://stackoverflow.com/help/someone-answers) – merv May 21 '19 at 16:15
  • 1
    @nerv "echo $CONDA_PREFIX" in [another question that answers how to determine the active env](https://stackoverflow.com/questions/36539623/how-do-i-find-the-name-of-the-conda-environment-in-which-my-code-is-running) is helpful. – 임정섭 May 23 '19 at 00:09
  • 3
    Glad it solved your issue. You're right for using `$CONDA_PREFIX`, but be careful that it is a component internal to conda, it was added in the 4.4 branch and is not guaranteed to be stable forever. – FabienP May 23 '19 at 04:26