admin管理员组

文章数量:1128307

I'm trying to find out what the path of the micromamba executable is that is used when I invoke micromamba in my zsh shell (so that I can upgrade the executable as I'm using v2.0.2 instead of the latest).

I've tried which micromamba but that just returns an unhelpful zsh function and not the actual executable path:

$ which micromamba
micromamba () {
    __mamba_wrap "${@}"
}

How can I find the actual location, similar to the way which python returns /Users/home/micromamba/envs/py13/bin/python?

I'm trying to find out what the path of the micromamba executable is that is used when I invoke micromamba in my zsh shell (so that I can upgrade the executable as I'm using v2.0.2 instead of the latest).

I've tried which micromamba but that just returns an unhelpful zsh function and not the actual executable path:

$ which micromamba
micromamba () {
    __mamba_wrap "${@}"
}

How can I find the actual location, similar to the way which python returns /Users/home/micromamba/envs/py13/bin/python?

Share Improve this question asked Jan 8 at 14:09 Cornelius RoemerCornelius Roemer 7,5713 gold badges49 silver badges95 bronze badges 5
  • 1 which __mamba_wrap? – robertklep Commented Jan 8 at 14:11
  • 1 I find it pretty helpful. You know that the command micromamba invokes the command __mamba_wrap, so this would be the next piece to hunt for. Maybe it is the binary you are looking for, maybe it is another function. – user1934428 Commented Jan 8 at 15:52
  • 1 what's the output of command -v micromamba? – Fravadona Commented Jan 8 at 17:01
  • 1 which -am '*mamba*' may be useful. The -m parameter allows a pattern; this will show the executables / functions / aliases / etc that are available with mamba in the name. – Gairfowl Commented Jan 8 at 17:18
  • @Fravadona ChatGPT also suggested that, alas, doesn't help: $ command -v micromamba outputs micromamba – Cornelius Roemer Commented Jan 8 at 17:33
Add a comment  | 

1 Answer 1

Reset to default 1

I found 4 ways of doing this, varying in generality:

Check the help text

It turns out, the executable's location is part of the default help message, on the line with "Usage":

$ micromamba
Version: 2.0.5

Usage: /Users/home/.local/bin/micromamba [OPTIONS] [SUBCOMMAND]

Options:
  -h,--help                   Print this help message and exit
...

Inspect shell function

The micromamba shell function calls __mamba_wrap, so let's which that:

$ which __mamba_wrap
__mamba_wrap () {
    \local cmd="${1-__missing__}"
    case "${cmd}" in
        (activate | reactivate | deactivate) __mamba_xctivate "${@}" ;;
        (install | update | upgrade | remove | uninstall) __mamba_exe "${@}" || \return
            __mamba_xctivate reactivate ;;
        (self-update) __mamba_exe "${@}" || \return
            if [ -f "/Users/home/.local/bin/micromamba.bkup" ]
            then
                rm -f "/Users/home/.local/bin/micromamba.bkup"
            fi ;;
        (*) __mamba_exe "${@}" ;;
    esac
}

This strongly suggests /Users/home/.local/bin/micromamba, but to confirm let's do:

$ which __mamba_exe
__mamba_exe () {
    (
        "/Users/home/.local/bin/micromamba" "${@}"
    )
}

Use which -a

which -a suggests the same path with less typing:

$ which -a micromamba
micromamba () {
    __mamba_wrap "${@}"
}
/Users/home/.local/bin/micromamba

Check manually in directories on $PATH

This one-liner does essentially the same as which -a (if I understand correctly what which -a does:

$ echo $PATH | tr ':' '\n' | xargs -I {} find {} -name micromamba 2>/dev/null
/Users/home/.local/bin/micromamba

本文标签: condaHow to I find out the real location of the micromamba executable binaryStack Overflow