mamba-org / mamba

The Fast Cross-Platform Package Manager
https://mamba.readthedocs.io
BSD 3-Clause "New" or "Revised" License
6.78k stars 348 forks source link

sbatch activate env #2999

Open Chandrima-04 opened 10 months ago

Chandrima-04 commented 10 months ago

Troubleshooting docs

How did you install Mamba?

Mambaforge

Search tried in issue tracker

slurm

Latest version of Mamba

Tried in Conda?

I do not have this problem with Conda, just with Mamba

Describe your issue

When am trying to create a slurm script to submit job, activating an environment is leading to issues. I tried both

micromamba activate env

as well as

eval "$(micromamba shell hook --shell )" micromamba activate metabat2

Error: `--shell: 1 required TEXT:{bash,cmd.exe,dash,fish,posix,powershell,tcsh,xonsh,zsh} missing Run with --help for more information. critical libmamba Shell not initialized

'micromamba' is running as a subprocess and can't modify the parent shell. Thus you must initialize your shell before using activate and deactivate.

To initialize the current shell, run: $ eval "$(micromamba shell hook --shell )" and then activate or deactivate with: $ micromamba activate To automatically initialize all future () shells, run: $ micromamba shell init --shell --root-prefix=~/micromamba If your shell was already initialized, reinitialize your shell with: $ micromamba shell reinit --shell Otherwise, this may be an issue. In the meantime you can run commands. See: $ micromamba run --help`

mamba info / micromamba info

No response

Logs

No response

environment.yml

No response

~/.condarc

No response

ahrib commented 10 months ago

I am also experiencing this issue with mamba installed via mambaforge on Windows (but not on MacOS with the same mamba version)

mamba activate env does not work conda activate env works as expected

mamba info

       mamba version : 1.5.3
     active environment : base
    active env location : C:\Users\username\AppData\Local\mambaforge
            shell level : 1
       user config file : C:\Users\username\.condarc
 populated config files : C:\Users\username\AppData\Local\mambaforge\.condarc
          conda version : 23.10.0
    conda-build version : not installed
         python version : 3.11.6.final.0
       virtual packages : __archspec=1=x86_64
                          __win=0=0
       base environment : C:\Users\username\AppData\Local\mambaforge  (writable)
      conda av data dir : C:\Users\username\AppData\Local\mambaforge\etc\conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/win-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : C:\Users\username\AppData\Local\mambaforge\pkgs
                          C:\Users\username\.conda\pkgs
                          C:\Users\username\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\username\AppData\Local\mambaforge\envs
                          C:\Users\username\.conda\envs
                          C:\Users\username\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/23.10.0 requests/2.31.0 CPython/3.11.6 Windows/10 Windows/10.0.19045 solver/libmamba conda-libmamba-solver/23.11.1 libmambapy/1.5.3
          administrator : True
             netrc file : None
           offline mode : False
jonashaag commented 10 months ago

How did you set up Conda/Mamba? What is the output? Can you please re-initialize your shell

ahrib commented 10 months ago

How did you set up Conda/Mamba? Originally using the Windows Mambaforge installer - a long time ago - windows lists the installer to be Mambaforge 4.12.0-0 (Python 3.9.10 64-bit) The base environment has been kept up to date with mamba update --all

What is the output? There was no output

Can you please re-initialize your shell I ran mamba init, then closed and re-opened the shell. This initially worked for me.. then i closed and re-opened the shell again and it no longer works. Re-running mamba init does not solve the issue even temporarily

For your reference, there is the mamba init output

(base) PS >  mamba init --all
no change     C:\Users\ahribern\AppData\Local\mambaforge\Scripts\conda.exe
no change     C:\Users\ahribern\AppData\Local\mambaforge\Scripts\conda-env.exe
no change     C:\Users\ahribern\AppData\Local\mambaforge\Scripts\conda-script.py
no change     C:\Users\ahribern\AppData\Local\mambaforge\Scripts\conda-env-script.py
no change     C:\Users\ahribern\AppData\Local\mambaforge\condabin\conda.bat
no change     C:\Users\ahribern\AppData\Local\mambaforge\Library\bin\conda.bat
no change     C:\Users\ahribern\AppData\Local\mambaforge\condabin\_conda_activate.bat
no change     C:\Users\ahribern\AppData\Local\mambaforge\condabin\rename_tmp.bat
no change     C:\Users\ahribern\AppData\Local\mambaforge\condabin\conda_auto_activate.bat
no change     C:\Users\ahribern\AppData\Local\mambaforge\condabin\conda_hook.bat
no change     C:\Users\ahribern\AppData\Local\mambaforge\Scripts\activate.bat
no change     C:\Users\ahribern\AppData\Local\mambaforge\condabin\activate.bat
no change     C:\Users\ahribern\AppData\Local\mambaforge\condabin\deactivate.bat
no change     C:\Users\ahribern\AppData\Local\mambaforge\Scripts\activate
no change     C:\Users\ahribern\AppData\Local\mambaforge\Scripts\deactivate
no change     C:\Users\ahribern\AppData\Local\mambaforge\etc\profile.d\conda.sh
no change     C:\Users\ahribern\AppData\Local\mambaforge\etc\fish\conf.d\conda.fish
no change     C:\Users\ahribern\AppData\Local\mambaforge\shell\condabin\Conda.psm1
no change     C:\Users\ahribern\AppData\Local\mambaforge\shell\condabin\conda-hook.ps1
no change     C:\Users\ahribern\AppData\Local\mambaforge\Lib\site-packages\xontrib\conda.xsh
no change     C:\Users\ahribern\AppData\Local\mambaforge\etc\profile.d\conda.csh
modified      C:\Users\ahribern\.bash_profile
modified      C:\Users\ahribern\.zshrc
modified      C:\Users\ahribern\.config\fish\config.fish
modified      C:\Users\ahribern\.xonshrc
modified      C:\Users\ahribern\.tcshrc
no change     C:\Users\ahribern\OneDrive - Capgemini\Documents\WindowsPowerShell\profile.ps1
no change     C:\Users\ahribern\OneDrive - Capgemini\Documents\PowerShell\profile.ps1
no change     HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun

==> For changes to take effect, close and re-open your current shell. <==

Added mamba to C:\Users\ahribern\.bash_profile
Added mamba to C:\Users\ahribern\.zshrc
Added mamba to C:\Users\ahribern\.config\fish\config.fish
Added mamba to C:\Users\ahribern\.tcshrc

==> For changes to take effect, close and re-open your current shell. <==
jonashaag commented 10 months ago

Please try to locate the Powershell init files and delete them (or the mamba related parts), then re-do initialization

ahrib commented 10 months ago

actions taken Two versions of powershell are installed on my Windows device. The first 'Windows Powershell' comes with the operating system, the second 'PowerShell' is installed when you want an up-to-date version e.g. 7.4

  1. I logged in to each powershell instance and deleted mamba related parts from all files listed by the powershell command $PROFILE | Select-Object *
  2. Closed & re-opened shell
  3. ran mamba init
  4. Closed & re-opened shell
  5. retest mamba activate env

test result - using PowerShell Same as previous mamba activate env doesnt work, but conda activate env does. No output is provided by the mamba activate command

Windows PowerShell Same as previous mamba activate env doesnt work, but conda activate env does. No output is provided by the mamba activate command

using PowerShell 7.4 Same as previous mamba activate env doesnt work, but conda activate env does. No output is provided by the mamba activate command

using Command Prompt I thought of trying with Command Prompt as an alternative. This Works as expected.

Possible ways forward? Is there some way to show or enable logs? This is quite strange as other conda wrapped commands work fine.

jonashaag commented 10 months ago

Hmm... maybe the two versions are the reason?

Maybe you can increase the log level during init. There is a command line flag to do it.

What's curious is that conda activate works, typically that means that there is an old version of Conda initializing somewhere.

Btw if you are such an advanced user why are you still using Powershell and not a Unix shell? 😛

jonashaag commented 10 months ago

Also is there any problem with just using conda activate?

ahrib commented 10 months ago

Hi Jonas, I have no option but Windows on my work device (no issues with my Mac at home)

maybe the two versions are the reason? Having two instances of powershell is normal on Windows, e.g. Poweshell 7 "Installs and runs side-by-side with Windows PowerShell" https://learn.microsoft.com/en-us/powershell/scripting/whats-new/migrating-from-windows-powershell-51-to-powershell-7?view=powershell-7.4

Both versions of Powershell experience the same issue, everything OK when using conda activate, but mamba activate results in no change

will do some further investigation.. I have a feeling there may be something to do with my PATH environment variable or some old mamba files sitting around as I have had it installed for so long

jonashaag commented 10 months ago

I meant installing a Unix shell on Windows

jonashaag commented 10 months ago

My proposal: remove everything that's Conda/Mamba related, install bash or Cygwin, install Micromamba or Pixi

ahrib commented 10 months ago

Thanks Jonas, that is significant a change that I am not keen on just yet. I would like to continue to use PS on Windows as it is a supported config.

Taking some of your thinking above, I plan on backing up my environments, remove everything mamba/conda related and re-install. e.g. performing a search on my device I can see multiple locations containing conda and mamba executables

Will advise how I go over the next few days.

ahrib commented 9 months ago

@jonashaag - my issue appears to be a duplicate of https://github.com/mamba-org/mamba/issues/1717 apologies I am not sure how I missed it previously.

I do not think my issue has anything to do with the OP - they appear to be on a *nix shell