{"record":{"id":"a73b0f25317f8465","repo":"pkgxdev/pkgx","slug":"could-not-find-most-major-version","errorCode":null,"errorMessage":"Could not find most major version","messagePattern":"Could not find most major version","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/lib/src/install.rs","lineNumber":190,"sourceCode":"            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\"))?;\n\n    if most_major.0 != installation.pkg.version {\n        return Ok(());\n    }\n\n    make_symlink(\n        shelf,\n        &format!(\"v{}\", installation.pkg.version.major),\n        installation,\n    )\n    .await?;\n\n    if installation.pkg.version == newest.0 {\n        make_symlink(shelf, \"v*\", installation).await?;\n    }\n\n    Ok(())\n}","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/pkgxdev/pkgx/blob/6de1d7e953b98061f69db95d4bd45a2a6ee5d7da/crates/lib/src/install.rs#L172-L208","documentation":"`symlink` also computes a `^major` requirement (due to a semverator bug it parses the bare major as a range) and `rfind`s the most major installed version. If none of the cellar's installed versions satisfies the major range it raises `Could not find most major version`. Like the minor check, this protects the symlink that aliases the 'most major' installation of a package.","triggerScenarios":"Calling `install()` for a project whose cellar versions list contains no version matching `^{major}` of installation.pkg.version — the major version of the package has never actually been installed/recorded, or the versions list is stale/empty at this point.","commonSituations":"Major-version upgrades where the old symlink pass ran against an outdated cellar snapshot, wiping the cellar between install steps in CI, or installing a prerelease/major that the version list doesn't include.","solutions":["Ensure the package version was actually installed before the symlink pass re-runs (check the cellar directory)","Re-run `pkgx install` so the versions list reflects current cellar state","Verify installation.pkg.version.major is the intended major (a wrong major yields an unsatisfiable range)","If it persists across clean installs, report as an upstream bug — the code itself notes an adjacent semverator bug"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"fn major_present(pkg_version: &str, installed: &[String]) -> bool {\n    let major = semver::Version::parse(pkg_version).unwrap().major;\n    installed.iter().any(|s| {\n        semver::Version::parse(s).map(|iv| iv.major == major).unwrap_or(false)\n    })\n}","typeGuard":null,"tryCatchPattern":"match install(&pkg, &config) {\n    Err(e) if e.to_string() == \"Could not find most major version\" => {\n        eprintln!(\"no installed major for {}; performing full install\", pkg.project);\n        // retry with a clean/full install path\n    }\n    Err(e) => return Err(e),\n    Ok(v) => Ok(v),\n}","preventionTips":["Never wipe the cellar between install and symlink steps in CI","Verify the major version was installed before re-running symlink-dependent logic","Watch for prerelease/major bumps that were never actually installed","If it reproduces deterministically, capture versions list and report upstream (semverator interplay)"],"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"}