microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
22.94k stars 6.33k forks source link

vcpkg.exe cannot determine the version of the downloaded nuget.exe. #38940

Closed kazssym closed 2 months ago

kazssym commented 4 months ago

Describe the bug vcpkg.exe cannot determine the version of the downloaded nuget.exe and stops its execution.

Environment

To Reproduce Steps to reproduce the behavior:

  1. ./vcpkg upgrade --no-dry-run
  2. See error
…(snip)
A suitable version of nuget was not found (required v6.10.0) Downloading portable nuget 6.10.0...
Downloading nuget...
https://dist.nuget.org/win-x86-commandline/v6.10.0/nuget.exe->F:\vcpkg\downloads\71d7307b-nuget.exe
Downloading https://dist.nuget.org/win-x86-commandline/v6.10.0/nuget.exe
error: nuget (F:\vcpkg\downloads\tools\nuget-6.10.0-windows\nuget.exe) produced unexpected output when attempting to determine the version:
NuGet バージョン: 6.10.0.107
使用方法: NuGet <command> [args] [options]
…(snip)

Expected behavior vcpkg.exe would continue the upgrade process.

Failure logs vcpkg.exe did not provide any log locations.

Additional context My environment uses the Japanese locale. nuget.exe 6.2.1 produced NuGet Version: 6.2.1.2 but 6.10.0 produces NuGet バージョン: 6.10.0.107. The localized output seems to be the cause.

JonLiu1993 commented 4 months ago

You should use ./vcpkg upgrade --no-dry-run instead of ./vcpkg install upgrade --no-dry-run, Can you directly use the command https://dist.nuget.org/win-x86-commandline/v6.10.0/nuget.exe to download nuget?

kazssym commented 4 months ago

You should use ./vcpkg upgrade --no-dry-run instead of ./vcpkg install upgrade --no-dry-run, Can you directly use the command https://dist.nuget.org/win-x86-commandline/v6.10.0/nuget.exe to download nuget?

The command was my mistake. It is indeed .\vcpkg.exe upgrade

kazssym commented 4 months ago

You should use ./vcpkg upgrade --no-dry-run instead of ./vcpkg install upgrade --no-dry-run, Can you directly use the command https://dist.nuget.org/win-x86-commandline/v6.10.0/nuget.exe to download nuget?

nuget.exe was actually downloaded under downloads\tools. The major difference between the two nuget.exe versions is no "version" strong is found in the 6.10 output.

DimRochette commented 4 months ago

Same issue with a French OS/Version Nuget tool is in french now and probably error parsing version

Nuget 6.2 (working)

NuGet Version: 6.2.1.2
usage: NuGet <command> [args] [options]
Type 'NuGet help <command>' for help on a specific command.

Nuget 6.10 (failed)

NuGet Version : 6.10.0.107
utilisation : NuGet <command> [args] [options]
Tapez 'NuGet help <command>' pour obtenir de l'aide sur une commande spécifique.
kazssym commented 4 months ago

I found code in vcpkg-tool expecting a fixed string to extract the nuget version as this:

                    return extract_prefixed_nonwhitespace("NuGet Version: ", Tools::NUGET, std::move(output), exe_path);
DimRochette commented 4 months ago

So the new space before the : break it

dg0yt commented 4 months ago

So the localisations break it: en: NuGet Version: 6.2.1.2
fr: NuGet Version : 6.10.0.107 OP: NuGet バージョン: 6.10.0.107

kazssym commented 4 months ago

I reverted the changes in f33c861 locally as a workaround to use vcpkg.

eAtmApp commented 4 months ago

I found code in vcpkg-tool expecting a fixed string to extract the nuget version as this:

                    return extract_prefixed_nonwhitespace("NuGet Version: ", Tools::NUGET, std::move(output), exe_path);

I recompiled the vcpkg-tool according to this and successfully solved the problem of NuGet outputting localized strings.

DimRochette commented 3 months ago

If your are here the quick fixes for windows vcpkg main branch failing on non English OS

Either go back 2 months ago to latest official tag working git checkout tags/2024.04.26

or just revert the problematic commit an use nugget 6.2 git revert f33c861

or recompile a vcpkg with the PR provided https://github.com/microsoft/vcpkg-tool/pull/1418

kazssym commented 3 months ago

microsoft/vcpkg-tool#1451 is another alternative pull request for vcpkg. The change should be minimal to solve this problem IMO.