pkgxdev/pkgx · error · anyhow::Error
Could not find most major version
Error message
Could not find most major version
What it means
`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.
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
Defensive patterns
Strategy: validation
Validate before calling
fn major_present(pkg_version: &str, installed: &[String]) -> bool {
let major = semver::Version::parse(pkg_version).unwrap().major;
installed.iter().any(|s| {
semver::Version::parse(s).map(|iv| iv.major == major).unwrap_or(false)
})
} Try / catch
match install(&pkg, &config) {
Err(e) if e.to_string() == "Could not find most major version" => {
eprintln!("no installed major for {}; performing full install", pkg.project);
// retry with a clean/full install path
}
Err(e) => return Err(e),
Ok(v) => Ok(v),
} Prevention
- 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)
When it happens
Trigger: 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.
Common situations: 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.
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
- Could not find most minor version for
- Could not get the base name of the installation path
- No inventory for
AI-assisted analysis of pkgxdev/pkgx@6de1d7e953 (2026-09-10).
Data as JSON: /api/errors/a73b0f25317f8465.
Report an issue: GitHub.
Appendix: source
Thrown at crates/lib/src/install.rs:190
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"))?;
if most_major.0 != installation.pkg.version {
return Ok(());
}
make_symlink(
shelf,
&format!("v{}", installation.pkg.version.major),
installation,
)
.await?;
if installation.pkg.version == newest.0 {
make_symlink(shelf, "v*", installation).await?;
}
Ok(())
}View on GitHub (pinned to 6de1d7e953)