0

I'd like to use mamba activate [env] in a shell script.

What would be the equivalent of conda shell.bash hook? I've tried mamba shell.bash hook and mamba shell hook -s posix.

dimid
  • 7,285
  • 1
  • 46
  • 85

2 Answers2

1

You can initialize mamba in your shell with the command mamba init.

However, you may want to run the hook subcommand in a non-interactive bash script where you need to activate an environment. There's no equivalent of conda shell.bash hook for mamba. To initialize mamba "on the fly", you must source the file $MAMBA_ROOT_PREFIX/etc/profile.d/mamba.sh, for example: source ~/miniconda3/etc/profile.d/mamba.sh.

You want to do this after initializing conda with eval "$(conda shell.bash hook)".

bepoli
  • 31
  • 8
0

By specifying the full path to your mamba installation, the following works:

source ~/.lib/mamba/bin/activate [env]
spawn
  • 192
  • 3
  • 9