{"record":{"id":"c7d04f1856c3e65f","repo":"stride3d/stride","slug":"could-not-find-installation-path-for-package-identity","errorCode":null,"errorMessage":"Could not find installation path for package {identity}","messagePattern":"Could not find installation path for package (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/assets/Stride.Core.Packages/NugetStore.cs","lineNumber":671,"sourceCode":"    /// </summary>\n    /// <remarks>It is safe to call it concurrently be cause we operations are done using the FileLock.</remarks>\n    /// <param name=\"package\">Package to uninstall.</param>\n    public async Task UninstallPackage(NugetPackage package, ProgressReport progress)\n    {\n#if DEBUG\n        var installedPackages = GetPackagesInstalled([package.Id]);\n        Debug.Assert(installedPackages.FirstOrDefault(p => p.Equals(package)) is not null);\n#endif\n        using (GetLocalRepositoryLock())\n        {\n            currentProgressReport = progress;\n            try\n            {\n                var identity = new PackageIdentity(package.Id, package.Version.ToNuGetVersion());\n\n                // Notify that uninstallation started.\n                var installPath = GetInstalledPath(identity.Id, identity.Version.ToPackageVersion())\n                    ?? throw new InvalidOperationException($\"Could not find installation path for package {identity}\");\n                OnPackageUninstalling(this, new PackageOperationEventArgs(new PackageName(package.Id, package.Version), installPath));\n\n                var projectContext = new EmptyNuGetProjectContext()\n                {\n                    ActionType = NuGetActionType.Uninstall,\n                    PackageExtractionContext = new PackageExtractionContext(PackageSaveMode.Defaultv3, XmlDocFileSaveMode.Skip, null, NativeLogger),\n                };\n\n                // Simply delete the installed package and its .nupkg installed in it.\n                await Task.Run(() => FileSystemUtility.DeleteDirectorySafe(installPath, true, projectContext));\n\n                // Notify that uninstallation completed.\n                OnPackageUninstalled(this, new PackageOperationEventArgs(new PackageName(package.Id, package.Version), installPath));\n                //currentProgressReport = progress;\n                //try\n                //{\n                //    manager.UninstallPackage(package.IPackage);\n                //}","sourceCodeStart":653,"sourceCodeEnd":689,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/assets/Stride.Core.Packages/NugetStore.cs#L653-L689","documentation":"NugetStore throws this InvalidOperationException during package uninstall when GetInstalledPath returns null, i.e. the package identity (Id + version) is registered but no on-disk installation directory can be located. It guards against proceeding with an uninstall of a package that is not physically present.","triggerScenarios":"Calling Uninstall (or an API that reaches the uninstall flow) with a PackageIdentity whose install path cannot be resolved by GetInstalledPath, typically because the package folder is missing or its name/version directory does not match the expected layout.","commonSituations":"The package directory was manually deleted or moved; the store path points to a stale/corrupted package cache; version string mismatch between the recorded version and the folder name (e.g. after a downgrade or partial install).","solutions":["Verify the package folder exists under the store's package path (PackagesPath) for the exact Id and version before uninstalling","Remove the stale package entry from the store's installed list (or reinstall the package) so the recorded identity matches the disk layout","Point the NugetStore at the correct PackagesPath containing the actual installation","As a last resort, delete the corrupted store metadata and reinstall the package through the manager"],"exampleFix":"// before\nawait store.Uninstall(package);\n// after\nvar installedPath = store.GetInstalledPath(package.Id, package.Version.ToPackageVersion());\nif (installedPath == null)\n{\n    // skip or refresh store state\n    await store.RemoveFromInstalledList(package); // or reinstall\n}\nelse\n{\n    await store.Uninstall(package);\n}","handlingStrategy":"validation","validationCode":"if (store.GetInstalledPath(package.Id, package.Version.ToPackageVersion()) == null)\n    throw new InvalidOperationException($\"Package {package.Id} {package.Version} not installed on disk\");","typeGuard":"bool IsInstalled(NugetStore store, PackageIdentity id) =>\n    store.GetInstalledPath(id.Id, id.Version.ToPackageVersion()) != null;","tryCatchPattern":"try { await store.Uninstall(package); }\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"Could not find installation path\"))\n{\n    // refresh store state / skip uninstall\n}","preventionTips":["Always resolve GetInstalledPath before uninstall operations","Never manually delete package folders; use the store's uninstall API","Keep PackagesPath stable and point the store at the right directory"],"tags":["nuget","packages","uninstall","filesystem"],"backgroundTag":"resource-not-found","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}