Prototype a new set of Cargo “plumbing” commands
| Metadata | |
|---|---|
| Point of contact | Ed Page |
| Status | Proposed |
| Needs | Contributor |
| Roadmap | Building blocks |
| Tracking issue | rust-lang/rust-project-goals#264 |
| Zulip channel | N/A (an existing stream can be re-used or new streams can be created on request) |
| Teams | cargo |
| Task owners | (none) |
Summary
- Refactor Cargo to allow hacks in proposed cargo-plumbing commands to be removed (cargo-plumbing#82).
- Round out proposed commands (issues)
- Finalize the message formats (cargo-plumbing#18)
Needs contributor: This goal needs contributors to refactor Cargo internals, implement remaining plumbing commands, optimize performance, and iterate on output schemas. The work is primarily in rust-lang/cargo and crate-ci/cargo-plumbing. Estimated time commitment: TBD.
Motivation
Cargo is a “porcelain” (UX) focused command and is highly opinionated which can work well for common cases. However, as Cargo scales into larger applications, users need the ability to adapt Cargo to their specific processes and needs.
The status quo
While most Cargo commands can be used programmatically, they still only operate at the porcelain level. Currently, Cargo’s plumbing commands are
cargo read-manifest:- works off of a
Cargo.tomlfile on disk - uses a custom json schema
- deprecated
- works off of a
cargo locate-project:- works off of a
Cargo.tomlfile on disk - text or json output, undocumented json schema
- uses a pre-1.0 term for package
- works off of a
cargo metadata:- works off of
Cargo.toml,Cargo.lockfiles on disk - uses a custom json schema
- can include dependency resolution but excludes feature resolution
- some users want this faster
- some users want this to report more information
- See also open issues
- works off of
cargo pkgid:- works off of
Cargo.toml,Cargo.lockfiles on disk - text output
- works off of
cargo verify-project:- works off of a
Cargo.tomlfile on disk - uses a custom json schema
- uses a pre-1.0 term for package
- deprecated
- works off of a
There have been experiments for a plumbing for builds
--build-planattempts to report what commands will be run so external build tools can manage them.- The actual commands to be run is dynamic, based on the output of build scripts from build graph dependencies
- Difficulty in supporting build pipelining
--unit-graphreports the graph the build operates off of which corresponds to calls to the compiler and build scripts- Also provides a way to get the results of feature resolution
Thanks to GSoC, we now have prototypes for some plumbing commands.
The next 6 months
Continue on the third-party subcommand to experiment with plumbing commands (source).
| Task | Owner(s) or team(s) | Notes |
|---|---|---|
| Refactor cargo | ||
| Implement remaining commands | ||
| Inside Rust blog post inviting feedback | Ed Page | |
| Optimizing Cargo | ||
| Iterate on schemas including schema evolution plan |
See 2025h2 goal for more background.
The “shiny future” we are working towards
- Collect user feedback on these commands and iterate on them for eventual inclusion into Cargo
- Evaluate refactoring Cargo to better align with these plumbing commands to have better boundaries between subsystems
- Evaluate splitting the
cargo[lib]into crates for each of these plumbing commands as smaller, more approachable, more “blessed” Rust APIs for users to call into
Team asks
| Team | Support level | Notes |
|---|---|---|
| cargo | Small | PR reviews for Cargo changes; design discussions |