Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotnet tool package cache bug #28695

Open
lovettchris opened this issue Oct 20, 2022 · 3 comments
Open

dotnet tool package cache bug #28695

lovettchris opened this issue Oct 20, 2022 · 3 comments
Assignees
Labels
Area-Tools untriaged Request triage from a team member
Milestone

Comments

@lovettchris
Copy link

lovettchris commented Oct 20, 2022

Describe the bug

The dotnet tool install cache C:\Users\clovett\.dotnet\toolResolverCache\1 can hold stale information that makes dotnet tool commands fail.

To Reproduce

Make sure you do not have the dotnet tool dotnet-ilverify installed globally.
Make sure the latest nuget.exe is in your PATH

  1. git clone https://github.com/microsoft/coyote to the folder "c:\git\coyote"
  2. cd coyote
  3. pwsh -f Scripts\build.ps1 -ci -nuget
  4. pwsh -f Scripts\run-tests.ps1 -ci

Now move "c:\git\coyote" to "c:\git\microsoft\coyote"

Try step 4 again and you will see an error from "dotnet ilverify" saying it cannot find it.

Exceptions (if any)

GracefulException

Specifically because the dotnet-ilverify info in "C:\Users\clovett.dotnet\toolResolverCache\1\dotnet-ilverify" contains stale information "PathToExecutable":"D:\git\coyote\packages\dotnet-ilverify\6.0.0\tools/net6.0/any/ILVerify.dll" (this path no longer exists because I moved the repo to a different place on my hard drive).

What it could do is detect that this is a local tool request and that PathToExecutable is not in the local folder.
It could also detect that the PathToExecutable FOLDER doesn't exist and remove that from the cache all together (which is the workaround for me that got things working again).

Better yet, locally installed tools should not use ANY global information from "C:\Users\clovett.dotnet" so that I can get 100% reproduceable environment when I do a fresh git clone, which is the point of locally installed dotnet tools in the first place.

Further technical details

  • Include the output of dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.402
 Commit:    6862418796

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

global.json file:
  Not found

Host:
  Version:      6.0.10
  Architecture: x64
  Commit:       5a400c212a

.NET SDKs installed:
  3.1.423 [C:\Program Files\dotnet\sdk]
  5.0.401 [C:\Program Files\dotnet\sdk]
  6.0.302 [C:\Program Files\dotnet\sdk]
  6.0.402 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.29 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.29 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.19 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.29 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

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

Learn about .NET Runtimes and SDKs:
  https://aka.ms/dotnet/runtimes-sdk-info
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version
    VS 2022 version 17.2.6, Windows 11.
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Tools untriaged Request triage from a team member labels Oct 20, 2022
@huw-dhcw
Copy link

I'm encountering the same issue when the %UserProfile%.nuget cache folder is cleared.
This creates the situation where the %UserProfile%.dotnet\toolResolverCache\1 contains a .tool file with a PathToExecutable referring to a dll that no longer exists in the .nuget folder.
I think dotnet tool restore is just checking the toolResolverCache for presence of the .tool file without checking that it contains valid paths.

@baronfel baronfel added this to the Backlog milestone Jan 30, 2024
@baronfel
Copy link
Member

The tool package cache should give a more usable error when the tool package cannot be found. At minimum it should remove the tool metadata from the cache.

More broadly, local tools should not store information in a shared global location - as it stands local tools of different versions in different repos clobber each other. There should be some level of context-awareness to the local tool install that prevents this clobbering.

@HaGGi13
Copy link

HaGGi13 commented Feb 7, 2025

This bug is really a pain when dotnet tools (in my case GitVersion.Tool) were installed and afterwards the global package cache path was changed.
It took me a while till I stumbled about this issue on GitHub that pointed me to my issue's cause.


Following I just explain what I did and tried to fix it.

I installed GitVersion.Tools with the original global package cache path (C:\Users\<user>\.nuget\packages\). So in folder C:\Users\<user>\.dotnet\toolResolverCache a file gitversion.tool was created with following content:

[
  {
    "Version": "6.1.0",
    "TargetFramework": "net8.0",
    "RuntimeIdentifier": "any",
    "Name": "dotnet-gitversion",
    "Runner": "dotnet",
    "PathToExecutable": "C:\\Users\\<user>\\.nuget\\packages\\gitversion.tool\\6.1.0\\tools/net8.0/any/gitversion.dll"
  }
]

I executed GitVersion (dotnet gitversion) w/o any issues, all worked fine.
Then I had to change the global package cache folder to C:\PRJ\.nuget\packages\ and I tried to run GitVersion again that failed with:
Run "dotnet tool restore" to make the "dotnet-gitversion" command available.

I executed dotnet tool restore w/o any success. So I uninstalled GitVersion.Tool and installed it again, w/o any success. It can be observed that the toolResolverCache entry does not change.
It still points to the original global cache path.

In the end I deleted the cache entry and installed the tool again to make it work.
It would be awesome if the cache would be cleaned up when a dotnet tool was uninstalled, so a reinstall would fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Tools untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

4 participants