-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Currently, workflow for rust developers is something like the following:
git clone ...
cd my_project
# part 1 of the workflow:
cargo install cargo-watch --ver 6.0.0
cargo install cargo-release
cargo install cargo-outdated --ver 0.7.0
cargo install .... # more installs of 3rd party extensions to enable automated management of a project
# part 2 of the workflow:
cargo build
cargo watch
cargo release
cargo outdated
cargo ... # more other commands
I noticed that new setup of a development machine or CI box requires consistent installation / synchronization of the required tools and their versions, which is part 1 of the workflow in the example above.
I have raised more detailed problem description here and it seems there was no a solution found.
I see that required tools and their versions are perfect match for dependencies specification in the Cargo.toml file. For example, cargo could support install-dependencies
section, like the following:
[install-dependencies]
cargo-watch = "6.0.0"
cargo-outdated = "0.7.0"
.... and so on for all the tools mentioned in README docs for developers and required to manage a project
If it was available, the workflow could become something like this:
git clone ...
cd my_project
# part 1 of the workflow:
cargo install
# part 2 of the workflow:
cargo build
cargo watch
cargo release
cargo outdated
cargo ... # more other commands
Notice cargo install
without arguments. It means cargo would read from the toml file and installs accordingly to install-dependencies
. This gives 2 benefits:
- solves the problem like: "readme tells run cargo release when you need to release, but there is no such cargo command available"
- solves the problem like: "readme tells run cargo release when you need to release, but running it fails, because the currently installed version OR enabled features of the tool are too old or not compatible with the current version of a project or compiler version"
Having the above functionality (running cargo install
without arguments) would bring cargo to be on par with npm install
(note: yes, I know npm install
also installs package and dev dependencies, but I am not suggesting this for cargo, hence new install-dependencies
section is proposed for the toml file only for binary-crate tools).
However, cargo can do even better than npm
in this area. cargo install
could be invoked implicitly on the first run of unknown command. This way the workflow becomes as simple as this:
git clone ...
cd my_project
# part 1 of the workflow:
# nothing to do
# part 2 of the workflow:
cargo build
cargo watch
cargo release
cargo outdated
cargo ... # more other native, 3rd party commands or aliases
This way all commands, either cargo native or 3rd party or aliases, look the same, their source and nature are not that important anymore. All 3rd party tools and their compatible versions are declared by a project on per project basis and installed automatically on need basis (for example, once first unknown command is invoked).