{"record":{"id":"35037f3e1d5fe043","repo":"pkgxdev/pkgx","slug":"could-not-find-most-minor-version-for","errorCode":null,"errorMessage":"Could not find most minor version for {}","messagePattern":"Could not find most minor version for (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/lib/src/install.rs","lineNumber":172,"sourceCode":"\n    let v_mm = format!(\n        \"{}.{}\",\n        installation.pkg.version.major, installation.pkg.version.minor\n    );\n    let minor_range = if installation.pkg.version.major > 0 {\n        VersionReq::caret(&v_mm)?\n    } else {\n        VersionReq::parse(&format!(\n            \">={},<0.{}\",\n            v_mm,\n            installation.pkg.version.minor + 1\n        ))?\n    };\n    let most_minor = versions\n        .iter()\n        .rfind(|(version, _)| minor_range.satisfies(version))\n        .ok_or_else(|| {\n            anyhow::anyhow!(\n                \"Could not find most minor version for {}\",\n                installation.pkg.project\n            )\n        })?;\n\n    if most_minor.0 != installation.pkg.version {\n        return Ok(());\n    }\n\n    make_symlink(shelf, &format!(\"v{}\", v_mm), installation).await?;\n\n    // bug in semverator\n    let major_range = VersionReq::parse(&format!(\"^{}\", installation.pkg.version.major))?;\n\n    let most_major = versions\n        .iter()\n        .rfind(|(version, _)| major_range.satisfies(version))\n        .ok_or_else(|| anyhow::anyhow!(\"Could not find most major version\"))?;","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/pkgxdev/pkgx/blob/6de1d7e953b98061f69db95d4bd45a2a6ee5d7da/crates/lib/src/install.rs#L154-L190","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run `pkgx install <pkg>` fresh so the cellar versions list is rebuilt and contains the version you expect","Verify the target version actually exists in the cellar directory for that project","Check the parsed version of installation.pkg.version — a malformed or unexpected version produces an unsatisfiable minor range","Report the issue with the project name in the message; an empty-satisfying-list over a non-empty cellar indicates a bookkeeping bug"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"use semverator::VersionReq;\nfn minor_range_satisfiable(pkg_version: &str, installed: &[String]) -> bool {\n    let v = semver::Version::parse(pkg_version).expect(\"valid version\");\n    let req = VersionReq::parse(&format!(\"^{}.{}\", v.major, v.minor)).unwrap();\n    installed.iter().any(|s| {\n        semver::Version::parse(s).map(|iv| req.satisfies(&iv)).unwrap_or(false)\n    })\n}","typeGuard":null,"tryCatchPattern":"match install(&pkg, &config) {\n    Err(e) if e.to_string().starts_with(\"Could not find most minor version\") => {\n        eprintln!(\"cellar missing expected version for {}; reinstalling\", pkg.project);\n        // re-run install or repair cellar\n    }\n    Err(e) => return Err(e),\n    Ok(v) => Ok(v),\n}","preventionTips":["Don't hand-delete version directories from the cellar; use the CLI to uninstall","Keep pkg.version and the cellar contents in sync in scripts","After wiping a cellar, run a fresh install rather than incremental symlink steps","Log cellar contents before scripted installs to catch drift early"],"tags":["install","symlink","semver","versioning"],"backgroundTag":"record-not-found","analyzedSha":"6de1d7e953b98061f69db95d4bd45a2a6ee5d7da","analyzedAt":"2026-09-10T09:59:03.886Z","contentChangedAt":"2026-09-10T09:59:03.886Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}