diff --git a/libmamba/data/micromamba.nu b/libmamba/data/micromamba.nu index 5583dc53c2..f18742bd04 100644 --- a/libmamba/data/micromamba.nu +++ b/libmamba/data/micromamba.nu @@ -8,16 +8,18 @@ def-env "micromamba activate" [name: string] { ) if $env.MAMBA_SHLVL? == null { - $env.MAMBA_SHLVL = "0" + $env.MAMBA_SHLVL = 0 } + # fetch path of current environment and update if present let p = ($envs | transpose key value | find $name) if ($p | length) >= 1 { let path = ([($p.value.0 | ansi strip) "bin"] | path join) if not $path in $env.PATH { $env.PATH = ($env.PATH | prepend $path) - $env.MICROMAMBA_CURRENT_ENV = ($p.key.0 | ansi strip) + $env.MAMBA_CURRENT_ENV = ($p.key.0 | ansi strip) + $env.CONDA_PREFIX = ($p.value.0 | ansi strip| path join condabin) } } } @@ -30,11 +32,19 @@ def-env "micromamba deactivate" [] { } ) # fetch path of current environment and remove current environment - let p = ($envs | transpose key value | find $env.MICROMAMBA_CURRENT_ENV) + let p = ($envs | transpose key value | find $env.MAMBA_CURRENT_ENV) if ($p | length) >= 1 { - let path = ([$p.value.0 "bin"] | path join) - $env.PATH = ($env.PATH | filter {|it| $it != $path}) - $env.MICROMAMBA_CURRENT_ENV = "" + let path = ([$p.value.0 "bin"] | path join) + $env.PATH = ($env.PATH | filter {|it| $it != $path}) + $env.MAMBA_CURRENT_ENV = "" + $env.CONDA_PREFIX = ($env.MAMBA_ROOT_PREFIX | path join condabin ) } } +# adding conda bin in current env +if $env.CONDA_SHLVL? == null { + $env.CONDA_SHLVL = 0 + let conda_prefix = ($env.MAMBA_ROOT_PREFIX | path join condabin ) + $env.PATH = ( $env.PATH | append $conda_prefix) + $env.CONDA_PREFIX = $conda_prefix +} diff --git a/libmamba/src/core/shell_init.cpp b/libmamba/src/core/shell_init.cpp index 14fb5b0770..217bc807e3 100644 --- a/libmamba/src/core/shell_init.cpp +++ b/libmamba/src/core/shell_init.cpp @@ -407,10 +407,10 @@ namespace mamba content << "\n# >>> mamba initialize >>>\n"; content << "# !! Contents within this block are managed by 'mamba init' !!\n"; - content << "$env.MICROMAMBA_MAMBA_EXE = " << mamba_exe << "\n"; - content << "$env.MICROMAMBA_ROOT_PREFIX = " << env_prefix << "\n"; - content << "$env.MICROMAMBA_CURRENT_ENV = \"\"\n"; - content << "$env.PATH = ($env.PATH | append ([$env.MICROMAMBA_ROOT_PREFIX bin] | path join) | uniq)\n"; + content << "$env.MAMBA_EXE = " << mamba_exe << "\n"; + content << "$env.MAMBA_ROOT_PREFIX = " << env_prefix << "\n"; + content << "$env.MAMBA_CURRENT_ENV = \"\"\n"; + content << "$env.PATH = ($env.PATH | append ([$env.MAMBA_ROOT_PREFIX bin] | path join) | uniq)\n"; content << "source " << env_prefix.string() << "/etc/profile.d/micromamba.nu\n"; content << "# <<< mamba initialize <<<\n"; return content.str(); diff --git a/mamba/mamba/shell_templates/micromamba.nu b/mamba/mamba/shell_templates/micromamba.nu index 5583dc53c2..f18742bd04 100644 --- a/mamba/mamba/shell_templates/micromamba.nu +++ b/mamba/mamba/shell_templates/micromamba.nu @@ -8,16 +8,18 @@ def-env "micromamba activate" [name: string] { ) if $env.MAMBA_SHLVL? == null { - $env.MAMBA_SHLVL = "0" + $env.MAMBA_SHLVL = 0 } + # fetch path of current environment and update if present let p = ($envs | transpose key value | find $name) if ($p | length) >= 1 { let path = ([($p.value.0 | ansi strip) "bin"] | path join) if not $path in $env.PATH { $env.PATH = ($env.PATH | prepend $path) - $env.MICROMAMBA_CURRENT_ENV = ($p.key.0 | ansi strip) + $env.MAMBA_CURRENT_ENV = ($p.key.0 | ansi strip) + $env.CONDA_PREFIX = ($p.value.0 | ansi strip| path join condabin) } } } @@ -30,11 +32,19 @@ def-env "micromamba deactivate" [] { } ) # fetch path of current environment and remove current environment - let p = ($envs | transpose key value | find $env.MICROMAMBA_CURRENT_ENV) + let p = ($envs | transpose key value | find $env.MAMBA_CURRENT_ENV) if ($p | length) >= 1 { - let path = ([$p.value.0 "bin"] | path join) - $env.PATH = ($env.PATH | filter {|it| $it != $path}) - $env.MICROMAMBA_CURRENT_ENV = "" + let path = ([$p.value.0 "bin"] | path join) + $env.PATH = ($env.PATH | filter {|it| $it != $path}) + $env.MAMBA_CURRENT_ENV = "" + $env.CONDA_PREFIX = ($env.MAMBA_ROOT_PREFIX | path join condabin ) } } +# adding conda bin in current env +if $env.CONDA_SHLVL? == null { + $env.CONDA_SHLVL = 0 + let conda_prefix = ($env.MAMBA_ROOT_PREFIX | path join condabin ) + $env.PATH = ( $env.PATH | append $conda_prefix) + $env.CONDA_PREFIX = $conda_prefix +} diff --git a/micromamba/tests/test_shell.py b/micromamba/tests/test_shell.py index 0a57e2e3a7..b2ed15a082 100644 --- a/micromamba/tests/test_shell.py +++ b/micromamba/tests/test_shell.py @@ -26,7 +26,7 @@ def skip_if_shell_incompat(shell_type): @pytest.mark.parametrize( "shell_type", - ["bash", "posix", "powershell", "cmd.exe", "xonsh", "zsh", "fish", "tcsh"], + ["bash", "posix", "powershell", "cmd.exe", "xonsh", "zsh", "fish", "tcsh", "nu"], ) def test_hook(tmp_home, tmp_root_prefix, shell_type): res = helpers.shell("hook", "-s", shell_type)