cargo-compatible
cargo-compatible is a Cargo subcommand for finding the highest dependency graph that still fits a chosen Rust version or MSRV.
It focuses on five workflows:
cargo compatible scancargo compatible resolvecargo compatible apply-lockcargo compatible suggest-manifestcargo compatible explain <crate-or-pkgid>
What It Does
- Reads the current workspace graph through
cargo metadata --format-version 1. - Selects the target Rust version from
--rust-version, selected package metadata, or mixed-workspace analysis. - Marks resolved packages as:
- incompatible when
package.rust-versionis higher than the selected target - unknown when
package.rust-versionis missing
- incompatible when
- Shows dependency paths from selected workspace members to problematic packages.
- Builds candidate lockfiles in a temporary workspace without mutating your real checkout.
- Applies a saved candidate lockfile only on explicit command.
- Suggests conservative direct dependency requirement changes for crates.io dependencies when lockfile-only resolution is not enough, using Cargo's sparse local registry cache when available.
Safety Model
scannever mutates user files.resolveworks in a temp copy of the workspace by default.apply-lockrequires an explicit candidate lockfile path.suggest-manifestis dry-run by default.- Missing dependency
rust-versionmetadata is treated as unknown, not compatible.
Installation
After installation, the subcommand is available as cargo compatible.
Quick Start
Command Notes
cargo compatible scan
Use this first to see the current workspace state.
cargo compatible resolve
Creates a temp workspace copy and runs stable Cargo resolution there.
cargo compatible apply-lock
Writes a previously saved candidate lockfile back to the real workspace.
cargo compatible suggest-manifest
Finds remaining direct dependency constraints after a best-effort lockfile-only pass.
cargo compatible explain
Explains why a package is present and why it is incompatible or unknown.
JSON Output Shape
The JSON reports are intentionally structured around stable sections instead of raw command text.
scantargetworkspacepackage_summariesincompatible_packagesunknown_packagesnotes
resolvecurrentcandidateversion_changesimproved_packagesremaining_blockerscandidate_lockfilenotes
suggest-manifestcandidate_resolutionmanifest_suggestionswrite_manifests
explainquerytargetpackagecurrent_statuscurrent_reasoncurrent_pathscurrent_rust_versioncandidate_versioncandidate_statusblockernotes
Current Limitations
- Manifest suggestions are intentionally conservative and currently focus on normal direct dependencies.
- Manifest suggestions depend on crates.io sparse index entries already present in the local Cargo cache; uncached crates are reported conservatively with no rewrite suggestion.
- Feature validation uses registry feature names and optional dependency feature inference; it does not model every Cargo feature edge case.
resolvecurrently re-runs Cargo in a full temp copy of the workspace, which favors correctness and safety over speed.- Resolver guidance for virtual workspaces is surfaced as a recommendation; this version does not auto-edit
workspace.resolver. - Path and git dependencies are analyzed and explained, but they do not receive bogus registry downgrade suggestions.
Development
Install the cargo subcommands used by CI if you do not already have them:
The test and verification stack now includes:
proptestinvariants for semver candidate selection and resolution-diff behaviorcargo-nextestfor the main integration and property test suitecargo-denyfor advisory, license, and source-policy checkscriterionfor a synthetic large-workspace resolver benchmark
Run the standard local verification commands with:
Run the full resolver benchmark locally with:
Tracing is opt-in and uses standard RUST_LOG filtering:
RUST_LOG=cargo_compatible=debug
License
MIT. See LICENSE.