Skip to content

Commit

Permalink
Add Micromamba support (nushell#800)
Browse files Browse the repository at this point in the history
I initially tried to get Micromamba to work with Nushell by using the
script from [this
issue](nushell#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.
  • Loading branch information
enzalito committed Mar 26, 2024
1 parent 3cee758 commit 41fe58e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions modules/virtual_environments/nu_conda_2/conda.nu
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}

Expand Down Expand Up @@ -173,4 +179,4 @@ def system-path [] {

def has-env [name: string] {
$name in $env
}
}

0 comments on commit 41fe58e

Please sign in to comment.