From 41fe58eceeaf24e560dc448280be3a143207982f Mon Sep 17 00:00:00 2001 From: Enzo Einhorn <52015993+enzalito@users.noreply.github.com> Date: Tue, 26 Mar 2024 19:47:45 +0100 Subject: [PATCH] Add Micromamba support (#800) I initially tried to get Micromamba to work with Nushell by using the script from [this issue](https://github.com/nushell/nu_scripts/issues/578). But even after fixing the syntax errors I couldn't activate any env. With these modifications, Micromamba seems to be working fine. Please note that I'm far from a Nu expert so my code might not be very idiomatic. If that is the case please tell me so and I'll be happy to do the necessary changes. --- modules/virtual_environments/nu_conda_2/conda.nu | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/virtual_environments/nu_conda_2/conda.nu b/modules/virtual_environments/nu_conda_2/conda.nu index 13021e861..ccbd3e062 100644 --- a/modules/virtual_environments/nu_conda_2/conda.nu +++ b/modules/virtual_environments/nu_conda_2/conda.nu @@ -2,7 +2,13 @@ def --env load-conda-info-env [] { if (not (has-env CONDA_INFO)) { export-env { $env.CONDA_INFO = ( - if not (which mamba | is-empty) { + if not (which micromamba | is-empty) { + mut info = micromamba env list --json | from json + let extra_info = micromamba info --json | from json + $info.envs_dirs = $extra_info."envs directories" + $info.root_prefix = $extra_info."base environment" + $info + } else if not (which mamba | is-empty) { (mamba info --envs --json --no-banner | from json) } else if not (which conda | is-empty) { (conda info --envs --json | from json) @@ -21,7 +27,7 @@ export def --env activate [ load-conda-info-env let conda_info = $env.CONDA_INFO if ($conda_info == null) { - print "Error: No Conda or Mamba install could be found in the environment. Please install either and add them to the environment. See: https://www.nushell.sh/book/environment.html for more info" + print "Error: No Conda, Mamba or Micromamba install could be found in the environment. Please install either and add them to the environment. See: https://www.nushell.sh/book/environment.html for more info" return } @@ -173,4 +179,4 @@ def system-path [] { def has-env [name: string] { $name in $env -} \ No newline at end of file +}