Cargo subcommand for proper use of -Z minimal-versions
.
Click to show a complete list of options
```console $ cargo minimal-versions --help cargo-minimal-versions
Cargo subcommand for proper use of -Z minimal-versions.
USAGE:
cargo minimal-versions
SUBCOMMANDS: build check test ... ```
To check all crates with minimal version dependencies:
sh
cargo minimal-versions check --workspace
Normally, crates with publish = false
do not need minimal version check. You can skip these crates by using --ignore-private
flag.
sh
cargo minimal-versions check --workspace --ignore-private
Using -Z minimal-versions
in the usual way will not work properly in many cases. To use cargo check
with -Z minimal-versions
properly, you need to run at least three processes.
If I remember correctly,
cargo check -Z minimal-versions
doesn't really do anything. It needs to be separated intocargo update -Z minimal-versions
andcargo check
.Also, dev-dependencies may raise version requirements. Ideally, remove them before run
cargo update -Z minimal-versions
. (Also, note thatCargo.lock
is actually shared within the workspace. However as far as I know, there is no workaround for this yet.)
In addition, due to cargo's feature integration, it is not correct to run cargo check
or cargo build
with -p
(--package
) or --workspace
(--all
) or on virtual manifest. To handle this problem correctly, you need the workspace handling provided by subcommands such as cargo hack
.
cargo-minimal-versions addresses most of these issues and makes it easy to run cargo commands with -Z minimal-versions
.
See #1 for the remaining problem.
cargo-minimal-versions requires nightly
toolchain (to run cargo update -Z minimal-versions
) and [cargo-hack] (to run cargo check
& cargo build
proper):
sh
rustup toolchain add nightly
cargo install cargo-hack
sh
cargo +stable install cargo-minimal-versions
Compiler support: requires rustc 1.60+
You can download prebuilt binaries from the Release page. Prebuilt binaries are available for macOS, Linux (gnu and musl), and Windows (static executable).
Example of script to download cargo-minimal-versions
```sh
host=$(rustc -Vv | grep host | sed 's/host: //')
curl -LsSf https://github.com/taiki-e/cargo-minimal-versions/releases/latest/download/cargo-minimal-versions-$host.tar.gz | tar xzf - -C $HOME/.cargo/bin ```
You can use taiki-e/install-action to install prebuilt binaries on Linux, macOS, and Windows. This makes the installation faster and may avoid the impact of problems caused by upstream changes.
yaml
- uses: taiki-e/install-action@cargo-hack
- uses: taiki-e/install-action@cargo-minimal-versions
You can install cargo-minimal-versions using Homebrew tap on macOS and Linux:
sh
brew install taiki-e/tap/cargo-minimal-versions
You can install cargo-minimal-versions using Scoop:
sh
scoop bucket add taiki-e https://github.com/taiki-e/scoop-bucket
scoop install cargo-minimal-versions
You can install cargo-minimal-versions using cargo-binstall:
sh
cargo binstall cargo-minimal-versions
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.