1

After installing micromamba (same with any flavor of conda), when my .bashrc loads I have an entry in my path like:

/home/users/balter/micromamba/condabin

It would be natural to think that this is the directory where one would find the conda executable, but not so:

balter@exahead1:~$ which micromamba
/usr/bin/which: no micromamba in (/home/groups/chse/Code/quality_measures:/home/groups/chse/Code/exacloud_utilities:/home/users/balter/micromamba/condabin:/home/users/balter/perl5/bin:/home/exacloud/software/spack/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/ibutils/bin:/opt/puppetlabs/bin:/opt/dell/srvadmin/bin:/home/users/balter/usr/bin:/home/users/balter/bin)
balter@exahead1:~$ ls micromamba/
bin    compiler_compat  COPYING  envs  fonts    lib      man   pyodbc.pyi  sbin   ssl  x86_64-conda_cos6-linux-gnu
cmake  conda-meta       docs     etc   include  libexec  pkgs  README      share  var  x86_64-conda-linux-gnu
balter@exahead1:~$ find . -type d -name "condabin"
balter@exahead1:~$ conda activate
(base) balter@exahead1:~$

So,

  1. My path contains a directory that doesn't exist.
  2. I can run a command, e.g. micromamba, that which doesn't know the location of.

How does this work, and what is the purpose of ~/micromamba/condabin?

abalter
  • 9,663
  • 17
  • 90
  • 145
  • 1
    Micromamba is not just another Conda. Very different beast. – merv Apr 12 '23 at 22:19
  • I do know that. However this aspect applies to both. Feel free to base your answer on either. – abalter Apr 13 '23 at 05:59
  • Possible duplicate: https://stackoverflow.com/a/75874698/570918 I.e., some symlinks and entry points are created there to always keep essential software on PATH when **base** isn’t activated. – merv Apr 13 '23 at 13:05
  • @merv -- some similarities. But your answer there states "Conda sets up condabin as a directory to always keep on PATH primarily so that the conda command can be available when base is not activated." However, the directory `.../condabin` DOES NOT exist whether or not I have micromamba activated. So how does it ensure "that the conda command can be available when base is not activated." And still, how can I user the command `micromamba activate` when the `micromamba` executable doesn't even exist according to `which`? – abalter Apr 14 '23 at 17:17

1 Answers1

4

I can run a command, e.g. micromamba, that which doesn't know the location of.

This is because you probably have the mamba initialize block somewhere in your ~/.bashrc (or ~/.bash_profile if on Windows or macOS) which looks something like this:

# >>> mamba initialize >>>
# !! Contents within this block are managed by 'mamba init' !!
export MAMBA_EXE="/opt/homebrew/bin/micromamba";
export MAMBA_ROOT_PREFIX="/Users/pavel/micromamba";
__mamba_setup="$("$MAMBA_EXE" shell hook --shell bash --prefix "$MAMBA_ROOT_PREFIX" 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__mamba_setup"
else
    if [ -f "/Users/pavel/micromamba/etc/profile.d/micromamba.sh" ]; then
        . "/Users/pavel/micromamba/etc/profile.d/micromamba.sh"
    else
        export  PATH="/Users/pavel/micromamba/bin:$PATH"  # extra space after export prevents interference from conda init
    fi
fi
unset __mamba_setup
# <<< mamba initialize <<<

Here, "$MAMBA_EXE" shell hook --shell bash --prefix "$MAMBA_ROOT_PREFIX" gets called where the function micromamba is defined.

So you can call micromamba activate even if micromamba is not in $PATH because it is a function. If you call type micromamba you should get the function definition

micromamba() {
    \local cmd="${1-__missing__}"
    case "$cmd" in
        activate|deactivate)
            __mamba_activate "$@"
            ;;
        install|update|upgrade|remove|uninstall)
            __mamba_exe "$@" || \return
            __mamba_reactivate
            ;;
        self-update)
            __mamba_exe "$@" || \return

            # remove leftover backup file on Windows
            if [ -f "$MAMBA_EXE.bkup" ]; then
                rm -f $MAMBA_EXE.bkup
            fi
            ;;
        *)
            __mamba_exe "$@"
            ;;
    esac
}

what is the purpose of ~/micromamba/condabin?

The condabin directory is for the shell initialization scripts for powershell and cmd.exe. Here you can see which shell initialization scripts should lie where. bash and zsh initialization scripts are in ~/micromamba/etc/profile.d/ and cmd.exe as well as powershell are in ~/micromamba/condabin/.

pavelzw
  • 66
  • 3