mamba icon indicating copy to clipboard operation
mamba copied to clipboard

Could not find Windows version by calling 'ver'

Open NinjaCats opened this issue 1 year ago • 1 comments

Troubleshooting docs

  • [X] My problem is not solved in the Troubleshooting docs

Anaconda default channels

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

How did you install Mamba?

Micromamba

Search tried in issue tracker

type::bug

Latest version of Mamba

  • [x] My problem is not solved with the latest version

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

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

that command the found in powershell

  • ver: The term 'ver' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

and run cmd /c ver

  • Microsoft Windows [Ver 10.0.19045.4651]

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

NinjaCats avatar Jul 22 '24 10:07 NinjaCats

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.

nekomeowww avatar Sep 07 '24 04:09 nekomeowww

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

Unfortunately that's not always accurate. In my test system I get:

  • CMD's ver: 10.0.22631.4602
  • Powershell's $PSVersionTable.BuildVersion: 10.0.22621.4391
  • wmic os get version: 10.0.22631

I'm standardizing this at https://github.com/conda/ceps/pull/103 and it was a bit more complicated than I thought. It does look like wmic os get version is an acceptable workaround if cmd /D /C ver cannot be run.

jaimergp avatar Dec 17 '24 22:12 jaimergp