Migration Guide: v0.19 to v0.20
Cargo MSRV 0.20.0 adds improved Cargo workspace support and tries to more strictly determine up front whether a
project is a cargo project or not (called bare). This is cargo-msrv's mode.
If you only run cargo-msrv on a single crate, or are in a bare project (i.e. a project without Cargo), or didn't use
json or minimal output formats, you probably won't need to do anything but be aware that cargo-msrv may run on a
workspace iso a single package by default now.
Workspace flags come after the subcommand
In v0.19, the --workspace, --package and --exclude flags had to be given before the subcommand, for example
cargo msrv --workspace find. They now come after the subcommand (like cargo):
# v0.19
cargo msrv --package $crate_name find
# v0.20
cargo msrv find --package $crate_name
The cargo workspace flags are accepted by find, verify, show and set. Please refer to the
Cargo Workspace page for more on workspaces and how cargo-msrv
selects packages.
Subcommands run for each selected package
In v0.19, cargo msrv find and cargo msrv verify ran once, for the crate root. In v0.20, find, verify, show and
set run once for each selected package. In a workspace, this means you may now get a result for more than one package.
Consequently:
cargo msrv find --write-toolchain-filenow writes the toolchain file to the workspace root, since it applies to the whole workspace. It writes the highest MSRV it found.cargo msrv find --ignore-lockfileandcargo msrv verify --ignore-lockfilenow temporarily move the lockfile of the workspace.cargo msrv setandcargo msrv find --write-msrvno longer overwrite arust-versionwhich is inherited from the workspace (rust-version.workspace = true). Usecargo msrv set --workspace-msrvto set the workspace MSRV instead.- When a custom check command is used, the project is still checked once, as a whole. NB: This may change in a future release, please feel free to discuss feedback on GitHub's discussions or the issue tracker :)
New errors
When cargo-msrv detected a workspace, it previously just ignored it. Now it tries to more strictly differentiate between
the mode it is in (cargo or bare). Options which don't make sense outside of the cargo mode are now reported as errors:
- Using
--workspace,--package,--excludeor--manifest-pathoutside a Cargo project. - A Cargo project for which
cargo metadatafails, for example because itsCargo.tomlcan't be parsed.
Rust versions are parsed more strictly
Rust versions now reject leading zeros, like Cargo. For example, 1.05 is no longer accepted (use 1.5 instead).
The package.metadata.msrv key, which can be used as a fallback on Rust versions which don't support
package.rust-version yet, now only accepts full (three component, e.g. 1.56.0) or short (two component,
e.g. 1.56) versions, like Cargo's rust-version.
Building cargo-msrv from source
Only relevant if you build cargo-msrv from source:
The rust-changelog release source is now behind the rust-releases-changelog-source Cargo feature. It is enabled
by default, so this only matters if you build cargo-msrv with --no-default-features.
Output formats
json
Refer to the JSON output format page for the complete descriptions of the events.
Selected packages
The selected_packages event has been replaced by the context_finalized event. Besides the selected packages, it also
reports whether cargo-msrv runs in a Cargo project, and whether that project is a workspace. Where selected_packages only
reported the detected and selected Cargo packages, we now instead send one event which reports details about the context the
program will run with (the context provides "resolved" configuration and environment values. If you use cargo-msrv as a library
instead of a CLI, you could do all the work of gathering config values yourself and only call cargo-msrv with just context values).
While the actual context does contain more than just the mode, workspace or packages, the event is currently limited to these.
If you feel that more values from the context should be reported, please open an issue or topic on the discussion forum.
Previously:
{
"type": "selected_packages",
// `null` when not in a Cargo project
"package_names": [
{
"name": "a",
"path": "/workspace/a/Cargo.toml"
}
]
}
Replacement:
{
"type": "context_finalized",
"project": {
"mode": "cargo",
"workspace": true,
"packages": [
{
"name": "a",
"path": "/workspace/a/Cargo.toml"
}
]
}
}
When not in a Cargo project, project.mode is bare, and the workspace and packages fields are absent.
Results for each package
Since subcommands now run for each selected package, you may receive more than one subcommand_result event. Each
of event now has a new package field, which tells you which package the result is for.
{
"type": "subcommand_result",
"subcommand_id": "show",
"package": {
"name": "a",
"path": "/workspace/a/Cargo.toml"
},
"result": {
"version": "1.56.0",
"manifest_path": "/workspace/a/Cargo.toml"
}
}
{
"type": "subcommand_result",
"subcommand_id": "show",
"package": {
"name": "b",
"path": "/workspace/b/Cargo.toml"
},
"result": {
"version": "1.58.0",
"manifest_path": "/workspace/b/Cargo.toml"
}
}
The checks of find and verify for a single package are now wrapped in the new scoped check_package event.
minimal
When the mode is cargo and cargo-msrv detected a workspace with more than one package, cargo-msrv now outputs
the name of the package and followed by the found MSRV.
a 1.56.0
b 1.58.0
When there is a single package, the output is unchanged, e.g.:
1.56.0