Skip to content

fix(resolver): one-click recovery for stale PackageCache compile deadlock - #901

Open
YatogamiRaito wants to merge 5 commits into
IvanMurzak:mainfrom
YatogamiRaito:fix/nuget-resolver-deadlock-recovery
Open

fix(resolver): one-click recovery for stale PackageCache compile deadlock#901
YatogamiRaito wants to merge 5 commits into
IvanMurzak:mainfrom
YatogamiRaito:fix/nuget-resolver-deadlock-recovery

Conversation

@YatogamiRaito

Copy link
Copy Markdown

Summary

  • Adds a Force Reimport Package Cache menu item next to the existing Force Resolve NuGet DLLs one under Tools > AI Game Developer > Dependencies. It deletes this package's own extracted copy under Library/PackageCache/com.ivanmurzak.unity.mcp@* and calls UnityEditor.PackageManager.Client.Resolve() to force a genuine re-extraction.
  • Documents the recovery path (both menu items, plus the manual fallback) in the README under a new Troubleshooting section.

Motivation

Hit this in a real project (Unity 6000.7.0a2): Packages/manifest.json had been bumped to a newer plugin version while the Editor was closed. On next launch the Console showed CS0115: '...CredentialProvider': no suitable method found to override in UnityMcpPlugin.Config.cs — the on-disk NuGet DLLs (Assets/Plugins/NuGet) were stale relative to what the new source expected.

NuGetDependencyResolver's self-heal paths never got a chance to run:

Manually copying the correct-version DLLs into place fixed the CS0115, but revealed a second, unrelated issue: three .cs files under this package's Editor/Scripts/Services/ (AccountCredentialService.cs, ProjectInstanceService.cs, UnityTokenRefresher.cs) were present on disk with valid .meta files but were silently missing from the actual Roslyn compile args (verified by inspecting the generated .rsp file directly), producing CS0103 errors that look like a source bug but aren't. Neither AssetDatabase.Refresh() nor a full Editor restart cleared this — only deleting Library/PackageCache/com.ivanmurzak.unity.mcp@<hash> and forcing Client.Resolve() did.

This PR doesn't attempt to fix Unity's own domain-reload-blocks-on-any-compile-error behavior or its AssetDatabase import gap (both are outside this package's control), but it does give users a documented, one-click way out instead of having to reverse-engineer the recovery by hand.

Test plan

  • Verified the new menu action end-to-end against a live, real-world project (not this repo's own test projects): wrote the file into the project's resolved package cache via the plugin's own script-update-or-create tool (Roslyn-validated, waits for the resulting Unity recompile) — compiled clean.
  • Invoked NuGetResolverMenu.ForceReimportPackageCache() via reflection through the plugin's own script-execute tool against a healthy package cache, confirming it's safe to run when nothing is actually broken (idempotent): Console showed the expected [NuGet] log sequence (delete → RecompileGate.Reset()Client.Resolve() requested).
  • Confirmed Unity Package Manager re-extracted Library/PackageCache/com.ivanmurzak.unity.mcp@<hash> afterward with the same content/fingerprint, the Editor recompiled without errors, and the plugin's own MCP connection came back up and answered tool calls again.
  • Not covered: an automated EditMode/PlayMode test, since this is an Editor-only, disk/UPM-side-effecting menu action outside what the existing test harness (which runs pre-resolved projects) exercises.

🤖 Generated with Claude Code

…deadlock

When Packages/manifest.json is bumped to a newer plugin version while the
Editor is closed (e.g. via git pull or a direct manifest edit), the on-disk
NuGet DLLs or Unity's own Library/PackageCache copy of this package can be
left stale relative to what the new source expects. This surfaces as
CS0115 in UnityMcpPlugin.Config.cs or CS0103 in Editor/Scripts/** for types
that are actually present and correctly namespaced on disk.

NuGetDependencyResolver's self-heal paths ([InitializeOnLoad] and the
registeredPackages event from IvanMurzak#707) never get a chance to run here: Unity
refuses to reload the C# domain while any script has a compile error, and
that reload is exactly what both paths depend on. Verified in a live
project (Unity 6000.7.0a2) that neither waiting with the Editor open nor a
full Editor restart alone clears the stuck state — only deleting
Library/PackageCache/com.ivanmurzak.unity.mcp@* and forcing a genuine
Client.Resolve() does.

Add a "Force Reimport Package Cache" menu item next to the existing
"Force Resolve NuGet DLLs" one that automates that exact recovery, and
document both in the README so users hitting this symptom can find the
fix without reading source.
Copilot AI review requested due to automatic review settings July 17, 2026 18:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants