fix(resolver): one-click recovery for stale PackageCache compile deadlock - #901
Open
YatogamiRaito wants to merge 5 commits into
Open
fix(resolver): one-click recovery for stale PackageCache compile deadlock#901YatogamiRaito wants to merge 5 commits into
YatogamiRaito wants to merge 5 commits into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Tools > AI Game Developer > Dependencies. It deletes this package's own extracted copy underLibrary/PackageCache/com.ivanmurzak.unity.mcp@*and callsUnityEditor.PackageManager.Client.Resolve()to force a genuine re-extraction.Motivation
Hit this in a real project (Unity 6000.7.0a2):
Packages/manifest.jsonhad been bumped to a newer plugin version while the Editor was closed. On next launch the Console showedCS0115: '...CredentialProvider': no suitable method found to overrideinUnityMcpPlugin.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:[InitializeOnLoad]requires a successful domain reload, which Unity refuses while any script has a compile error.registeredPackagesevent workaround from NuGet resolver doesn't trigger after package upgrade when project has compile errors — [InitializeOnLoad] blocked, no domain reload #707 only helps for a package transition that happens while the Editor is already running — it doesn't apply to a cold start where the mismatch already exists on disk.Manually copying the correct-version DLLs into place fixed the CS0115, but revealed a second, unrelated issue: three
.csfiles under this package'sEditor/Scripts/Services/(AccountCredentialService.cs,ProjectInstanceService.cs,UnityTokenRefresher.cs) were present on disk with valid.metafiles but were silently missing from the actual Roslyn compile args (verified by inspecting the generated.rspfile directly), producingCS0103errors that look like a source bug but aren't. NeitherAssetDatabase.Refresh()nor a full Editor restart cleared this — only deletingLibrary/PackageCache/com.ivanmurzak.unity.mcp@<hash>and forcingClient.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
script-update-or-createtool (Roslyn-validated, waits for the resulting Unity recompile) — compiled clean.NuGetResolverMenu.ForceReimportPackageCache()via reflection through the plugin's ownscript-executetool 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).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.🤖 Generated with Claude Code