Devolutions/UniGetUI · warning · InvalidOperationException

APT does not support installing arbitrary versions

Error message

APT does not support installing arbitrary versions

What it means

Apt's GetInstallableVersions_UnSafe unconditionally throws InvalidOperationException because apt only installs the candidate version exposed by the configured repositories and cannot pin arbitrary versions. The base class calls this when the UI/API asks for the list of installable versions for a package.

Source

Thrown at src/UniGetUI.PackageEngine.Managers.Apt/Helpers/AptPkgDetailsHelper.cs:161

        // Must drain all stdout before WaitForExit — packages with many files
        // will fill the pipe buffer and deadlock if we stop reading early.
        string? result = null;
        string? line;
        while ((line = p.StandardOutput.ReadLine()) is not null)
        {
            if (result is not null) continue;
            var path = line.Trim();
            if (Directory.Exists(path))
                result = path;
        }

        p.StandardError.ReadToEnd();
        p.WaitForExit();
        return result;
    }

    protected override IReadOnlyList<string> GetInstallableVersions_UnSafe(IPackage package)
        => throw new InvalidOperationException("APT does not support installing arbitrary versions");
}

View on GitHub (pinned to 9b1d7d0eab)

Solutions

  1. Gate UI/automation on the manager's Capabilities: only request versions when Supports ArbitraryVersions (or equivalent capability) is true.
  2. For apt, install without specifying a version (use the repository candidate) and disable the version-picker control.
  3. Catch InvalidOperationException around version-fetching and fall back to the single candidate version from package details.

Example fix

// before
var versions = await pkg.GetInstallableVersionsAsync(); // throws for apt
// after
if (pkg.Manager.Capabilities.SupportsArbitraryVersions)
    versions = await pkg.GetInstallableVersionsAsync();
else
    versions = [pkg.Version];
Defensive patterns

Strategy: validation

Validate before calling

// Caller: only request versions when the manager supports it.
if (package.Manager.Capabilities.SupportsArbitraryVersions)
    versions = package.GetInstallableVersionsAsync();
else
    versions = new[] { package.Version };

Type guard

// Type guard on capability.
static bool CanListVersions(IPackage pkg) =>
    pkg.Manager.Capabilities.SupportsArbitraryVersions;

Prevention

When it happens

Trigger: Any code path that requests installable versions for an Apt package: the package details page version picker, or an operation that resolves available versions before install.

Common situations: UI tries to populate a 'choose version' dropdown for an apt package; automation requests version metadata expecting a list.

Related errors


AI-assisted analysis of Devolutions/UniGetUI@9b1d7d0eab (2026-08-13). Data as JSON: /api/errors/ea31b9cc4d3dd21e. Report an issue: GitHub.