pkgxdev/pkgx · error · anyhow::Error

Could not find most minor version for

Error message

Could not find most minor version for {}

What it means

During `symlink`, the code scans the local cellar's installed versions and uses `rfind` to locate the most minor version still satisfying the `^major.minor` requirement derived from the package being installed. If no entry in the cellar satisfies the minor range, it raises `Could not find most minor version for {project}`. This guards the symlink bookkeeping that points the 'most minor' alias at the right installation.

Solutions

  1. Run `pkgx install <pkg>` fresh so the cellar versions list is rebuilt and contains the version you expect
  2. Verify the target version actually exists in the cellar directory for that project
  3. Check the parsed version of installation.pkg.version — a malformed or unexpected version produces an unsatisfiable minor range
  4. Report the issue with the project name in the message; an empty-satisfying-list over a non-empty cellar indicates a bookkeeping bug
Defensive patterns

Strategy: validation

Validate before calling

use semverator::VersionReq;
fn minor_range_satisfiable(pkg_version: &str, installed: &[String]) -> bool {
    let v = semver::Version::parse(pkg_version).expect("valid version");
    let req = VersionReq::parse(&format!("^{}.{}", v.major, v.minor)).unwrap();
    installed.iter().any(|s| {
        semver::Version::parse(s).map(|iv| req.satisfies(&iv)).unwrap_or(false)
    })
}

Try / catch

match install(&pkg, &config) {
    Err(e) if e.to_string().starts_with("Could not find most minor version") => {
        eprintln!("cellar missing expected version for {}; reinstalling", pkg.project);
        // re-run install or repair cellar
    }
    Err(e) => return Err(e),
    Ok(v) => Ok(v),
}

Prevention

When it happens

Trigger: Calling `install()` when `versions` (the list of installed cellar versions for the project) contains no version satisfying the parsed minor range of the installation — e.g. the cellar was partially cleaned, the pkg.version was mutated to a minor version never installed, or version parsing filtered entries out.

Common situations: Manually deleting versions from ~/.pkgx/cellar while pkgx assumes they exist, installing a freshly bumped version in a script where the symlink pass runs against a stale versions list, or a semverator/VersionReq parsing quirk making the minor range unsatisfiable.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of pkgxdev/pkgx@6de1d7e953 (2026-09-10). Data as JSON: /api/errors/35037f3e1d5fe043. Report an issue: GitHub.

Appendix: source

Thrown at crates/lib/src/install.rs:172

    let v_mm = format!(
        "{}.{}",
        installation.pkg.version.major, installation.pkg.version.minor
    );
    let minor_range = if installation.pkg.version.major > 0 {
        VersionReq::caret(&v_mm)?
    } else {
        VersionReq::parse(&format!(
            ">={},<0.{}",
            v_mm,
            installation.pkg.version.minor + 1
        ))?
    };
    let most_minor = versions
        .iter()
        .rfind(|(version, _)| minor_range.satisfies(version))
        .ok_or_else(|| {
            anyhow::anyhow!(
                "Could not find most minor version for {}",
                installation.pkg.project
            )
        })?;

    if most_minor.0 != installation.pkg.version {
        return Ok(());
    }

    make_symlink(shelf, &format!("v{}", v_mm), installation).await?;

    // bug in semverator
    let major_range = VersionReq::parse(&format!("^{}", installation.pkg.version.major))?;

    let most_major = versions
        .iter()
        .rfind(|(version, _)| major_range.satisfies(version))
        .ok_or_else(|| anyhow::anyhow!("Could not find most major version"))?;

View on GitHub (pinned to 6de1d7e953)