Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Prototype a new set of Cargo “plumbing” commands

Metadata
Point of contactEd Page
StatusProposed
NeedsContributor
RoadmapBuilding blocks
Tracking issuerust-lang/rust-project-goals#264
Zulip channelN/A (an existing stream can be re-used or new streams can be created on request)
Teamscargo
Task owners(none)

Summary

  1. Refactor Cargo to allow hacks in proposed cargo-plumbing commands to be removed (cargo-plumbing#82).
  2. Round out proposed commands (issues)
  3. 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.toml file on disk
    • uses a custom json schema
    • deprecated
  • cargo locate-project:
    • works off of a Cargo.toml file on disk
    • text or json output, undocumented json schema
    • uses a pre-1.0 term for package
  • cargo metadata:
    • works off of Cargo.toml, Cargo.lock files 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
  • cargo pkgid:
    • works off of Cargo.toml, Cargo.lock files on disk
    • text output
  • cargo verify-project:
    • works off of a Cargo.toml file on disk
    • uses a custom json schema
    • uses a pre-1.0 term for package
    • deprecated

There have been experiments for a plumbing for builds

  • --build-plan attempts 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-graph reports 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).

TaskOwner(s) or team(s)Notes
Refactor cargoHelp wanted
Implement remaining commandsHelp wanted
Inside Rust blog post inviting feedbackEd Page
Optimizing CargoHelp wanted, Ed Page
Iterate on schemas including schema evolution planHelp wanted

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

TeamSupport levelNotes
cargoSmallPR reviews for Cargo changes; design discussions

Frequently asked questions