I want to install this crate: https://crates.io/crates/cargo-release, so I added it to [dev-dependencies] of Cargo.toml. But when I do cargo build,
cargo release command is not available. It became available only when I do
cargo install cargo-release.
Could somebody tell how to install this tool without
cargo install ? Is it possible to make it auto-installable by adding to [dev-dependencies] ?
dev-dependencies are merely dependencies (on library crates) for tests, examples, and benchmarks. If you want to get a cargo subcommand like
cargo-release, you'll have to install it yourself, just like e. g. you needed to install the rust compiler yourself, too.
I also tried to put it into main dependencies, but got same result. So, the only way here is direct install ?
You can't depend on binary (command) crates. You can only depend on library crates. All the commands you want to use, you have to install yourself.
Right. A dependency (in the sense of "dependencies" in the
Cargo.toml) is a library that your code depends on and uses (e. g. importing stuff with
There are some special cases where dependencies are (to a certain extend) more like executables than like libraries, because they are executed at built-time, which includes proc-macros or built-scripts.
But for cargo subcommands, installing them manually is the typical work flow.
Also note that you typically want to install
cargo release globally (for your user) on your system, whereas dependencies are crate-specific. And usually, you wouldn't want to re-build the
cargo release subcommand every time you do a clean build or a new crate, so a global / system-wide (at least for your current user) installation is usually appropriate.
On the topic of cargo subcommands, I can also recommend https://crates.io/crates/cargo-update to help keep things up to date.