mirror of
https://github.com/nushell/nu_scripts.git
synced 2024-10-26 13:55:28 +03:00
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.
This commit is contained in:
parent
3cee758551
commit
41fe58ecee
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user