Error installing .NET Core global tools: "Could not find a part of the path..."

Viewed 3233

.NET Core global tool installation fails on some Windows computers with this error:

Failed to install tool package 'amazon.lambda.tools': Could not find a part of the path 'C:\Users\myUser\.dotnet\tools\.store\.stage\xxx.yyy\amazon.lambda.tools'.
Tool 'amazon.lambda.tools' failed to install. This failure may have been caused by:

* You are attempting to install a preview release and did not use the --version option to specify the version.
* A package by this name was found, but it was not a .NET Core tool.
* The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
* You mistyped the name of the tool.

For more reasons, including package naming enforcement, visit https://aka.ms/failure-installing-tool

The above example attempts to install Amazon.Lambda.Tools; but other common tools (e.g. dotnetsay) give the same result.

I have only observed this in one environment: a Windows Server 2016 virtual machine which my development team uses as a TFS 2017 build agent. The server has Visual Studio 2017 and 2019 installed, as well as Visual Studio 2017 and 2019 Build Tools. The server is not behind a proxy. Other Windows Server 2016 virtual machines on the same VLAN are able to perform the installation successfully.

C:\Users\myUser>dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.1.101
 Commit:    b377529961

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.1.101\

Host (useful for support):
  Version: 3.1.1
  Commit:  a1388f194c

.NET Core SDKs installed:
  3.1.101 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

The following were unsuccessful:

  • Running as admin.
  • Running as various accounts (some have '.' in the user name, some don't).
  • Uninstalling .NET Core SDKs/runtimes, Visual Studio, then installing .NET Core by itself and attempting the tool install.
  • Rolling back to .NET Core 3.1.101 (original attempt was on 3.1.102).
  • Copying the .nupkg from a computer where the installation succeeded and using it as a file argument to --add-source (long-shot, I know).
  • Specifying a specific --version during the install.

I have identified a workaround: copy C:\Users\myUser.dotnet\tools from a computer where the installation succeeds to the same location on the computer where it fails. Doing so allows the use of the global tool as if the installation had succeeded. This is, of course, not an optimal solution, but I mention it in case it leads to a better understanding of the underlying problem.

I don't know the inner workings of the dotnet tool install command, but I can easily imagine "Could not find a part of the path..." to be the failure of a method which expects some downloaded content to be placed in a temporary folder, but finds that wasn't the case. If that's true, then this could be (as the error suggests) the result of a failed download...the logs just don't tell me what resource it failed to download, and I haven't been able to locate the .nupkg for Amazon.Lambda.Tools on Github (to try specifying the URL manually).

Is there a known resolution to this issue? If not, then are there any further steps I might take to diagnose the tool installation? I am convinced that the reported error "Could not find a part of the path..." is merely a side-effect of an error which is not visible to me via the console.

3 Answers

I ran into the same problem while installing Amazon.Lambda.Tools but specifing the package version resolved the issue for me:

dotnet tool install --global Amazon.Lambda.Tools --version 4.1.0

While running the below command resulted in the same error as you reported

dotnet tool install --global Amazon.Lambda.Tools

To ensure you are installing the latest version of this package check the nuget feed here.

I ran into this running the command on a fresh windows install.

dotnet tool install --global Amazon.Lambda.Tools

Turns out the error was quit explicit:

error NU1101: Unable to find package amazon.lambda.tools. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages

It was only looking for the package in the Microsoft Visual Studio Offline Packages repository.

I ran visual studio 2019, then checked the Package Sources settings for nuget from there then ran the command again and it installed fine.

I faced with the same issue. After lot of iterations I found that my MSBuildSDKsPath was wrong. Was C:\Program Files\dotnet\sdk\5.0.400 but should be C:\Program Files\dotnet\sdk\5.0.400\Sdks . After fix and reboot I can install tool

Related