-
Notifications
You must be signed in to change notification settings - Fork 145
Description
Feature Description
As discussed in #1062 and #1063, these aren't actually valid:
[tasks.install-some-crate]
install_crate = { crate_name "cargo-some-crate", version = "0.0.1" }
If used, the install_crate is deserialized into an InstallCargoPluginInfo, which has min_version, but not version. The result is that cargo make install-some-crate will attempt cargo install cargo-some-crate, and in particular, it won't use --locked, regardless of CARGO_MAKE_CRATE_INSTALLATION_LOCKED setting.
As a specific example, if the crate_name is cargo-nextest and the current version is outdated, cargo install nextest will fail because it explicitly requires the --locked flag.
As the above issues demonstrate, users are confused by this behavior.
Describe The Solution You'd Like
The documentation could perhaps be improved to reflect this more clearly (e.g. the section that says "If version is defined instead of min_version, [CARGO_MAKE_CRATE_INSTALLATION_LOCKED] will automatically be set as true." should probably mention that it only applies if binary and test_args are set as well.
In any case, rather than relying just on documentation, you could add an optional version field to the InstallCargoPluginInfo and report an error if it's not None.
Code Sample
#[derive(Serialize, Deserialize, Debug, Clone)]
/// Holds instructions how to install the cargo plugin
pub struct InstallCargoPluginInfo {
/// The provided crate to install
pub crate_name: Option<String>,
/// Minimal version
pub min_version: Option<String>,
/// Optional alternate 'install' command
pub install_command: Option<String>,
/// Optional add force flag (if needed), default is true
pub force: Option<bool>,
/// Used to detect user mistakes if they set the `version` field accidentally.
#[doc(hidden)]
pub version: Option<String>,
}