dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.67k stars 1.06k forks source link

[ppc64le][mono] dotnet tool update -g is failing #41672

Closed Swapnali911 closed 2 months ago

Swapnali911 commented 3 months ago

To Reproduce

Run dotnet tool update -g dotnet-trace

Actual :

Unhandled exception: System.ArgumentNullException: Value cannot be null. (Parameter 'key')
   at System.Collections.Generic.Dictionary`2[[System.CommandLine.CliSymbol, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35],[System.CommandLine.Parsing.SymbolResult, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].FindValue(CliSymbol key)
   at System.Collections.Generic.Dictionary`2[[System.CommandLine.CliSymbol, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35],[System.CommandLine.Parsing.SymbolResult, System.CommandLine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]].TryGetValue(CliSymbol key, SymbolResult& value)
   at System.CommandLine.Parsing.SymbolResultTree.GetResult(CliOption option)
   at System.CommandLine.Parsing.SymbolResult.GetResult(CliOption option)
   at System.CommandLine.ParseResult.GetResult(CliOption option)
   at Microsoft.DotNet.Tools.Tool.Common.ToolAppliedOption.EnsureNoConflictUpdateAllVersionOption(ParseResult parseResult, String message)
   at Microsoft.DotNet.Tools.Tool.Update.ToolUpdateCommand.Execute()
   at Microsoft.DotNet.Cli.ToolUpdateCommandParser.<>c.<ConstructCommand>b__5_0(ParseResult parseResult)
   at System.CommandLine.Invocation.AnonymousSynchronousCliAction.Invoke(ParseResult parseResult)
   at System.CommandLine.Invocation.InvocationPipeline.Invoke(ParseResult parseResult)
   at System.CommandLine.ParseResult.Invoke()
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, TimeSpan startupTime, ITelemetry telemetryClient)

Expected : dotnet tool update should work without any issue

Tarball Details :

# dotnet --info
.NET SDK:
 Version:           9.0.100-preview.5.24307.1
 Commit:            35b2c21ea6
 Workload version:  9.0.100-manifests.9b4ca231
 MSBuild version:   17.11.0-preview-24279-02+b963c24ef

Runtime Environment:
 OS Name:     rhel
 OS Version:  9
 OS Platform: Linux
 RID:         linux-ppc64le
 Base Path:   /home/check_tarball/.dotnet/sdk/9.0.100-preview.5.24307.1/

.NET workloads installed:
Configured to use loose manifests when installing new manifests.
There are no installed workloads to display.

Host:
  Version:      9.0.0-preview.5.24306.7
  Architecture: ppc64le
  Commit:       a5cc707d97

.NET SDKs installed:
  9.0.100-preview.5.24307.1 [/home/check_tarball/.dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 9.0.0-preview.5.24306.11 [/home/check_tarball/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 9.0.0-preview.5.24306.7 [/home/check_tarball/.dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  DOTNET_ROOT       [/home/check_tarball/.dotnet]

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

cc : @tmds @omajid @alhad-deshpande @ashwinik30

tmds commented 3 months ago

This is a Mono runtime issue. It happens also on x64.

The supposed null argument is the VersionOption that is passed here:

https://github.com/dotnet/sdk/blob/fda398e8bc6abf3ee455500c7f189db6f6800180/src/Cli/dotnet/commands/dotnet-tool/common/ToolAppliedOption.cs#L74

VersionOption a static that gets intialized from another class's static:

https://github.com/dotnet/sdk/blob/fda398e8bc6abf3ee455500c7f189db6f6800180/src/Cli/dotnet/commands/dotnet-tool/common/ToolAppliedOption.cs#L22

https://github.com/dotnet/sdk/blob/fda398e8bc6abf3ee455500c7f189db6f6800180/src/Cli/dotnet/commands/dotnet-tool/install/ToolInstallCommandParser.cs#L20-L24

The VersionOption was added in this PR https://github.com/dotnet/sdk/pull/38996 which is why we're only recently seeing this issue.

An easy workaround may be to initialize the VersionOption in ToolAppliedOption. The root cause seems some issue with the static initialization in Mono.

cc @lambdageek @uweigand

lambdageek commented 3 months ago

Probably related to https://github.com/dotnet/runtime/issues/88066 or https://github.com/dotnet/runtime/issues/77513

lambdageek commented 3 months ago

/cc @steveisok

marcpopMSFT commented 2 months ago

I believe that tmds fixed this in the linked issue so marking it closed.