← Back to issue list

cargo-use: support Rust workspaces better

View original Github issue

Metadata

Project
craft-parts
Number
#1217
Type
issue
State
open
Author
Saviq
Labels
Created
2025-08-26 06:59:10+00:00
Updated
2025-12-16 08:42:46+00:00
Closed

Current evaluation

No evaluation has been recorded for this issue yet.

Issue body

### What needs to get done It's common for Rust repositories to contain multiple packages/crates in a single workspace. The `cargo-use` plugin needs to better support this. `crate package` is the standard way to "render" a crate standalone, and here's a `build-override` that works well: ```yaml build-environment: - CARGO_PACKAGES: . clap_builder override-build: &package-override | REGISTRY=$( readlink -f ${CRAFT_PART_INSTALL}/../export/cargo-registry ) mkdir --parents "${REGISTRY}" for package in ${CARGO_PACKAGES}; do cd ${CRAFT_PART_BUILD}/$package cargo package --no-verify done cd ${CRAFT_PART_BUILD} for crate in target/package/*.crate; do tar xzvf "${crate}" -C "${REGISTRY}" echo '{"files":{}}' > ${REGISTRY}/$( basename ${crate%.crate} )/.cargo-checksum.json done ``` `crate package --workspace` could create all the packages in one go, but is unreliable (many repositories fail in a myriad ways) and some crates might not even be desirable in the output, so giving the user agency on which crates to work through is likely appropriate. ### Why it needs to get done Pointing at each crate in a workspace individually is tedious, wasteful (pulling the same source multiple times) and error prone: ``` :: Caused by: :: failed to parse manifest at `/root/backstage/cargo-registry/toml_datetime-0.6.8/Cargo.toml` :: Caused by: :: error inheriting `edition` from workspace root manifest's `workspace.package.edition` :: Caused by: :: failed to find a workspace root ``` This is because the crate tries to inherit metadata from the workspace, e.g.: https://github.com/toml-rs/toml/blob/9154dcb3b2eea8a84db183806411adf081bc0977/crates/toml_datetime/Cargo.toml#L7-L11

Evaluation history

No evaluation history available.