dotnet / interactive

.NET Interactive combines the power of .NET with many other languages to create notebooks, REPLs, and embedded coding experiences. Share code, explore data, write, and learn across your apps in ways you couldn't before.
MIT License
2.84k stars 378 forks source link

dotnet tool install --global Microsoft.dotnet-interactive fails with 401 (Unauthorized #3319

Open jmneto opened 9 months ago

jmneto commented 9 months ago

Describe the bug

Visual Studio Code Polyglot Notebooks stopped working. It is stuck in Installing .net Interactive.

When I try to install via command line: dotnet tool install --global Microsoft.dotnet-interactive --version 1.0.456201

It fails with this error: Unhandled exception: System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 (Unauthorized - No local versions of package 'microsoft.dotnet-interactive'; please provide authentication to access versions from upstream that have not yet been saved to your feed. (DevOps Activity ID: 89A38BDA-FA03-45B6-9F6D-B1F4072285B5)). at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode() at NuGet.Protocol.HttpSource.<>cDisplayClass15_01.<<GetAsync>b__0>d.MoveNext() --- End of stack trace from previous location --- at NuGet.Common.ConcurrencyUtilities.ExecuteWithFileLockedAsync[T](String filePath, Func2 action, CancellationToken token) at NuGet.Common.ConcurrencyUtilities.ExecuteWithFileLockedAsync[T](String filePath, Func2 action, CancellationToken token) at NuGet.Protocol.HttpSource.GetAsync[T](HttpSourceCachedRequest request, Func2 processAsync, ILogger log, CancellationToken token) at NuGet.Protocol.PackageMetadataResourceV3.LoadRegistrationIndexAsync(HttpSource httpSource, Uri registrationUri, String packageId, SourceCacheContext cacheContext, Func2 processAsync, ILogger log, CancellationToken token) at NuGet.Protocol.PackageMetadataResourceV3.GetMetadataAsync(String packageId, Boolean includePrerelease, Boolean includeUnlisted, VersionRange range, SourceCacheContext sourceCacheContext, ILogger log, CancellationToken token) at NuGet.Protocol.PackageMetadataResourceV3.GetMetadataAsync(String packageId, Boolean includePrerelease, Boolean includeUnlisted, SourceCacheContext sourceCacheContext, ILogger log, CancellationToken token) at Microsoft.DotNet.Cli.NuGetPackageDownloader.NuGetPackageDownloader.GetPackageMetadataAsync(PackageSource source, String packageIdentifier, Boolean includePrerelease, Boolean includeUnlisted, CancellationToken cancellationToken) at Microsoft.DotNet.Cli.NuGetPackageDownloader.NuGetPackageDownloader.GetMatchingVersionInternalAsync(String packageIdentifier, IEnumerable1 packageSources, VersionRange versionRange, CancellationToken cancellationToken) at Microsoft.DotNet.Cli.NuGetPackageDownloader.NuGetPackageDownloader.GetBestPackageVersionAsync(PackageId packageId, VersionRange versionRange, PackageSourceLocation packageSourceLocation) at Microsoft.DotNet.Cli.ToolPackage.ToolPackageDownloader.<>c__DisplayClass8_0.b0() at Microsoft.DotNet.Cli.TransactionalAction.Run[T](Func`1 action, Action commit, Action rollback) at Microsoft.DotNet.Tools.Tool.Install.ToolInstallGlobalOrToolPathCommand.Execute() at System.CommandLine.Invocation.InvocationPipeline.Invoke(ParseResult parseResult) at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, TimeSpan startupTime, ITelemetry telemetryClient)

Please complete the following:

Which version of .NET Interactive are you using? (In a notebook, run the #!about magic command. ):

Trying to use Polyglot Notebooks v1.0.4562010 Trying to install version 1.0.456201

Screenshots

If applicable, add screenshots to help explain your problem. Screenshot 2023-11-14 180306

jmneto commented 9 months ago

More info:

dotnet tool install --global Microsoft.dotnet-interactive --version 1.0.456201 --verbosity diag

[NuGet Manager] [Info] GET https://api.nuget.org/v3/registration5-gz-semver2/microsoft.dotnet-interactive/index.json [NuGet Manager] [Info] GET https://microsofthealthoss.pkgs.visualstudio.com/7621b231-1a7d-4364-935b-2f72b911c43d/_packaging/a60b7c8b-c6ae-4a8e-bd15-a526b603a1f2/nuget/v3/registrations2-semver2/microsoft.dotnet-interactive/index.json [NuGet Manager] [Info] OK https://api.nuget.org/v3/registration5-gz-semver2/microsoft.dotnet-interactive/index.json 135ms [NuGet Manager] [Info] Unauthorized https://microsofthealthoss.pkgs.visualstudio.com/7621b231-1a7d-4364-935b-2f72b911c43d/_packaging/a60b7c8b-c6ae-4a8e-bd15-a526b603a1f2/nuget/v3/registrations2-semver2/microsoft.dotnet-interactive/index.json 456ms Unhandled exception: System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 (Unauthorized - No local versions of package 'microsoft.dotnet-interactive'; please provide authentication to access versions from upstream that have not yet been saved to your feed. (DevOps Activity ID: 196FA0BD-2585-4EB1-8E5A-BE7361486279)).

jmneto commented 9 months ago

After running the --verbosity diag that gave me a clue about a nuget source I had enabled years ago. Using dotnet nuget list source command I could list my sources:

dotnet nuget list source Registered Sources:

  1. nuget.org [Enabled] https://api.nuget.org/v3/index.json
  2. HDS [Enabled] https://microsofthealthoss.pkgs.visualstudio.com/FhirServer/_packaging/Public/nuget/v3/index.json
  3. Microsoft Visual Studio Offline Packages [Enabled] C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\

After disabling the HDS source everything is back working

dotnet nuget list source Registered Sources:

  1. nuget.org [Enabled] https://api.nuget.org/v3/index.json
  2. HDS [Disabled] https://microsofthealthoss.pkgs.visualstudio.com/FhirServer/_packaging/Public/nuget/v3/index.json
  3. Microsoft Visual Studio Offline Packages [Enabled] C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\

    However I still consider this a bug, because VS Code just gets stuck forever tying to install .net interactive as per screenshot above.

jmneto commented 9 months ago

I still consider this a bug, because VS Code just gets stuck forever tying to install .net interactive as per screenshot above. It required me a lot of troubleshoot to get this fixed. We cannot hang on installing .net interactive forever because of a permission issue on a Nuget Source that is not even relevant to the install.

IntegerMan commented 8 months ago

I would agree that this is a bug as well. I got the same issue tonight and it confused me as well. Turned out it was the private NuGet feed I have installed for Telerik controls. For me dotnet nuget disable source Telerik was the solution, followed by restarting VS Code.

An ideal solution would be either to bypass errors on NuGet sources and resume next, use a named NuGet source by default, or simply expose errors from the install.

MikeYeager commented 8 months ago

Same here. Thank you for this post. Definitely a bug.

cpwood commented 6 months ago

We also ran into this in a DevOps pipeline for .NET 6. Ended up having to hack around it by taking the NuGet.config file out of the equation since --ignore-failed-sources wasn't having any effect:

  - script: |
      mv NuGet.config NuGet.temp
      dotnet tool install --global coverlet.console --ignore-failed-sources --version 3.2.0
      dotnet tool install --global dotnet-reportgenerator-globaltool --ignore-failed-sources
      mv NuGet.temp NuGet.config
    displayName: Install tools
rwb196884 commented 2 months ago

I have to remove all non-nuget package sources from my C:\Users\%USERNAME%\AppData\Roaming\NuGet\NuGet.Config to get dotnet tool install to work. The --ignore-failed-sources option doens't do anything.

jonsequitur commented 1 month ago

I have to remove all non-nuget package sources from my C:\Users\%USERNAME%\AppData\Roaming\NuGet\NuGet.Config to get dotnet tool install to work. The --ignore-failed-sources option doens't do anything.

This sounds like it could be a NuGet bug.