stride3d/stride · error · InvalidOperationException

Could not find installation path for package

Error message

Could not find installation path for package {identity}

What it means

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.

Solutions

  1. Verify the package folder exists under the store's package path (PackagesPath) for the exact Id and version before uninstalling
  2. Remove the stale package entry from the store's installed list (or reinstall the package) so the recorded identity matches the disk layout
  3. Point the NugetStore at the correct PackagesPath containing the actual installation
  4. As a last resort, delete the corrupted store metadata and reinstall the package through the manager

Example fix

// before
await store.Uninstall(package);
// after
var installedPath = store.GetInstalledPath(package.Id, package.Version.ToPackageVersion());
if (installedPath == null)
{
    // skip or refresh store state
    await store.RemoveFromInstalledList(package); // or reinstall
}
else
{
    await store.Uninstall(package);
}
Defensive patterns

Strategy: validation

Validate before calling

if (store.GetInstalledPath(package.Id, package.Version.ToPackageVersion()) == null)
    throw new InvalidOperationException($"Package {package.Id} {package.Version} not installed on disk");

Type guard

bool IsInstalled(NugetStore store, PackageIdentity id) =>
    store.GetInstalledPath(id.Id, id.Version.ToPackageVersion()) != null;

Try / catch

try { await store.Uninstall(package); }
catch (InvalidOperationException ex) when (ex.Message.StartsWith("Could not find installation path"))
{
    // refresh store state / skip uninstall
}

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/c7d04f1856c3e65f. Report an issue: GitHub.

Appendix: source

Thrown at sources/assets/Stride.Core.Packages/NugetStore.cs:671

    /// </summary>
    /// <remarks>It is safe to call it concurrently be cause we operations are done using the FileLock.</remarks>
    /// <param name="package">Package to uninstall.</param>
    public async Task UninstallPackage(NugetPackage package, ProgressReport progress)
    {
#if DEBUG
        var installedPackages = GetPackagesInstalled([package.Id]);
        Debug.Assert(installedPackages.FirstOrDefault(p => p.Equals(package)) is not null);
#endif
        using (GetLocalRepositoryLock())
        {
            currentProgressReport = progress;
            try
            {
                var identity = new PackageIdentity(package.Id, package.Version.ToNuGetVersion());

                // Notify that uninstallation started.
                var installPath = GetInstalledPath(identity.Id, identity.Version.ToPackageVersion())
                    ?? throw new InvalidOperationException($"Could not find installation path for package {identity}");
                OnPackageUninstalling(this, new PackageOperationEventArgs(new PackageName(package.Id, package.Version), installPath));

                var projectContext = new EmptyNuGetProjectContext()
                {
                    ActionType = NuGetActionType.Uninstall,
                    PackageExtractionContext = new PackageExtractionContext(PackageSaveMode.Defaultv3, XmlDocFileSaveMode.Skip, null, NativeLogger),
                };

                // Simply delete the installed package and its .nupkg installed in it.
                await Task.Run(() => FileSystemUtility.DeleteDirectorySafe(installPath, true, projectContext));

                // Notify that uninstallation completed.
                OnPackageUninstalled(this, new PackageOperationEventArgs(new PackageName(package.Id, package.Version), installPath));
                //currentProgressReport = progress;
                //try
                //{
                //    manager.UninstallPackage(package.IPackage);
                //}

View on GitHub (pinned to 96fad776d2)