mamba-org / mamba

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

Could not find Windows version by calling 'ver' #3359

Open NinjaCats opened 4 months ago

NinjaCats commented 4 months ago

Troubleshooting docs

Anaconda default channels

How did you install Mamba?

Micromamba

Search tried in issue tracker

type::bug

Latest version of Mamba

Tried in Conda?

Not applicable

Describe your issue

I receive that bug;

conda was not installed on my computer

Shell Ver: PowerShell 7.4.3 System Ver: Microsoft Windows [Ver 10.0.19045.4651]

Discrabe

that command the found in powershell

and run cmd /c ver

mamba info / micromamba info

libmamba version : 1.5.8
     micromamba version : 1.5.8
           curl version : libcurl/8.2.1-DEV Schannel zlib/1.2.13
     libarchive version : libarchive 3.6.2 zlib/1.2.13 liblzma/5.4.3 bz2lib/1.0.8 liblz4/1.9.4 libzstd/1.5.5
       envs directories : C:\Users\*******\micromamba\envs
          package cache : C:\Users\*******\micromamba\pkgs
                          C:\Users\*******\.mamba\pkgs
                          C:\Users\*******\AppData\Roaming\.mamba\pkgs
            environment : None (not found)
           env location : -
      user config files : C:\Users\*******\.mambarc
 populated config files : C:\Users\*******\.condarc
       virtual packages : __win=0=0
                          __archspec=1=x86_64
               channels : https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/win-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/win-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/noarch
       base environment : C:\Users\*******\micromamba
               platform : win-64

Logs

No response

environment.yml

No response

~/.condarc

No response

nekomeowww commented 2 months ago

I encountered the same issue:

warning  libmamba Could not find Windows version by calling 'ver'
    Please file a bug report.
    Error: ��֧�ָ�����
warning  libmamba Not setting long path registry key; Windows version must be at least 10 with the fall 2016 "Anniversary update" or newer.

After a slight research, the official Microsoft documentation states that the ver command is only available in Windows CMD, while the installation script can only be executed in PowerShell, which conflict itself.

Fortunately, Microsoft suggests another official way to obtain the Windows version in PowerShell by going through:

> $PSVersionTable.BuildVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
10     0      19041  4842

There are tons of ways to obtain the System version: https://stackoverflow.com/questions/7330187/how-to-find-the-windows-version-from-the-powershell-command-line

After a brief inspection, I found that the issue was introduced to mamba by https://github.com/mamba-org/mamba/pull/3248 after Mar 28 with this line:

https://github.com/mamba-org/mamba/blob/327534724ab7c5c161a4f95349e440e1b50a5692/libmamba/src/util/os_win.cpp#L194

The workaround should be running the following command in CMD:

 C:\Users\
 ${user}\AppData\Local\micromamba\micromamba.exe shell init -s powershell -p C:\Users\${user}\micromamba

dedicated.

So the better approach to this Pull Request would be to have https://github.com/mamba-org/mamba/blob/327534724ab7c5c161a4f95349e440e1b50a5692/libmamba/src/util/os_win.cpp#L194 to distinguish different executable environment and use ver for CMD as well as using $PSVersionTable.BuildVersion in PowerShell.

I am not a CPP expert, I could help on contributing the fix by adding extra functions to handle the cases, but may need maintainers helps.

EDIT1:

Nevermind, I found the init functionality is broken too no matter running with:

micromamba shell init --shell powershell --root-prefix=~/micromamba
warning  libmamba Could not find Windows version by calling 'ver'
    Please file a bug report.
    Error: ��֧�ָ�����
warning  libmamba Not setting long path registry key; Windows version must be at least 10 with the fall 2016 "Anniversary update" or newer.

or what I mentioned:

 C:\Users\
 ${user}\AppData\Local\micromamba\micromamba.exe shell init -s powershell -p C:\Users\${user}\micromamba

EDIT2:

I am lost, running directly in CMD is broken too. I am switching to Linux to try again...

C:\Users\Yuna>micromamba shell init --shell cmd.exe --root-prefix=~/micromamba
Setting cmd.exe AUTORUN to: "C:\Users\Yuna\micromamba\condabin\mamba_hook.bat"
warning  libmamba Could not find Windows version by calling 'ver'
    Please file a bug report.
    Error: ��֧�ָ�����
warning  libmamba Not setting long path registry key; Windows version must be at least 10 with the fall 2.