Devolutions/UniGetUI · warning · InvalidOperationException

DNF does not support installing arbitrary versions

Error message

DNF does not support installing arbitrary versions

What it means

DNF's GetInstallableVersions_UnSafe unconditionally throws InvalidOperationException. DNF (Fedora/RHEL RPM) resolves versions from enabled repositories and does not expose an arbitrary-version install list, so the operation is unsupported.

Source

Thrown at src/UniGetUI.PackageEngine.Managers.Dnf/Helpers/DnfPkgDetailsHelper.cs:142

        // Must drain all stdout before WaitForExit — packages like glibc have thousands
        // of file entries and will fill the pipe buffer, causing a deadlock.
        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("DNF does not support installing arbitrary versions");

    private static long ParseDnfSize(string value)
    {
        // Format: "1.5 M", "234 k", "56 G"
        var parts = value.Split(' ', StringSplitOptions.RemoveEmptyEntries);
        if (parts.Length < 2 || !double.TryParse(parts[0],
                System.Globalization.NumberStyles.Any,
                System.Globalization.CultureInfo.InvariantCulture, out var num))
            return 0;

        return parts[1].ToUpperInvariant() switch
        {
            "K" => (long)(num * 1024),
            "M" => (long)(num * 1024 * 1024),
            "G" => (long)(num * 1024 * 1024 * 1024),
            _ => (long)num,
        };
    }

View on GitHub (pinned to 9b1d7d0eab)

Solutions

  1. Gate version requests on the manager capability flag (DNF reports no arbitrary-version support).
  2. Install via the repository default version and hide the version picker for DNF.
  3. Catch InvalidOperationException around version fetching and use the installed/available version string.

Example fix

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

Strategy: validation

Validate before calling

if (package.Manager.Capabilities.SupportsArbitraryVersions)
    versions = package.GetInstallableVersionsAsync();
else
    versions = new[] { package.Version };

Type guard

static bool CanListVersions(IPackage pkg) =>
    pkg.Manager.Capabilities.SupportsArbitraryVersions;

Prevention

When it happens

Trigger: Any code path requesting installable versions for a DNF package: details page version picker, or pre-install version resolution.

Common situations: UI version dropdown populated for a DNF package; automation expecting a version list.

Related errors


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