Skip to content

micromamba shell init doesn't work #3908

@chenyulue

Description

@chenyulue

Troubleshooting docs

  • My problem is not solved in the Troubleshooting docs

Anaconda default channels

  • I do NOT use the Anaconda default channels (pkgs/* etc.)

How did you install Mamba?

Micromamba

Search tried in issue tracker

Unexpected token 'activate' in expression or statement

Latest version of Mamba

  • My problem is not solved with the latest version

Tried in Conda?

I didn't try

Describe your issue

I use micromamba of version 2.1.0 in powershell. When I run micromamba shell init to initialize my powershell profile, I get the following script:

#region mamba initialize
# !! Contents within this block are managed by 'mamba shell init' !!
$Env:MAMBA_ROOT_PREFIX = "C:\Users\chenyulue\micromamba"
$Env:MAMBA_EXE = "C:\Users\chenyulue\micromamba\micromamba.exe"
(& $Env:MAMBA_EXE 'shell' 'hook' -s 'powershell' -r $Env:MAMBA_ROOT_PREFIX) | Out-String | Invoke-Expression
#endregion

When I start a new powershell, I get the errors as follows:

Invoke-Expression: C:\Users\chenyulue\Documents\PowerShell\profile.ps1:6
Line |
   6 |  … wershell' -r $Env:MAMBA_ROOT_PREFIX) | Out-String | Invoke-Expression
     |                                                        ~~~~~~~~~~~~~~~~~
     | Unexpected token 'activate' in expression or statement.

Then I check the output of $Env:MAMBA_EXE 'shell' 'hook' -s 'powershell' -r $Env:MAMBA_ROOT_PREFIX) | Out-String, and it is:

$MambaModuleArgs = @{ChangePs1 = $True}
Import-Module "$Env:MAMBA_ROOT_PREFIX\condabin\Mamba.psm1" -ArgumentList $MambaModuleArgs

"micromamba" activate base
Remove-Variable MambaModuleArgs

The problem comes from the line "micromamba" activate base, where micromamba is enclosed by quotes. The quotes should not be added. So this may be a bug for the micromamba of version 2.1.0.

The workaround is remove the quotes from the output string with the following script, and the error is gone:

(& $Env:MAMBA_EXE 'shell' 'hook' -s 'powershell' -r $Env:MAMBA_ROOT_PREFIX) | Out-String | foreach {$_.replace('"micromamba"', 'micromamba')} | Invoke-Expression

mamba info / micromamba info

Logs

environment.yml

~/.condarc

Metadata

Metadata

Assignees

No one assigned

    Labels

    type::bugSomething isn't workingwhere::windowsWindows-specific issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions