← Back to issue list

Rust plugin prevents from building a single package in workspace

View original Github issue

Metadata

Project
craft-parts
Number
#934
Type
issue
State
open
Author
artivis
Labels
—
Created
Updated
Closed
—

Current evaluation

Rust plugin hardcodes `cargo build --workspace` in the virtual-workspace branch, so users cannot build a single/selected package; the `rust_cargo_parameters` workaround fails. Still present at HEAD, untriaged and unacknowledged.

Suggested action: needs triage

Reason: The defect is confirmed still present at HEAD: rust_plugin.py:441 emits `cargo build --workspace --release {config_cmd_string}`, with `rust_cargo_parameters` (line 412-413) appended after the flag so cargo's `--workspace` precedence defeats the suggested workaround. The issue has zero labels, zero comments, and no assignee, and git history of rust_plugin.py shows only refactors (#530, #560, #626, #1424, #1706, #1745) with no fix commit, so it has never been assessed by a maintainer. Impact is moderate (blocks a legitimate, commonly needed use case in large workspaces) but not app-breaking, and the fix is small and well-understood since the reporter correctly notes cargo falls back to `default-members`/all-members when neither flag is given.

Evaluated by: mr-cal-bot

Impact: 35 Quick Win: 21 Complexity: 20 Confidence: 85 Actionability: 75

Issue body

### What needs to get done The rust plugin should support building a single (or several) package(s) in a virtual workspace. The `cargo build` command offers the `--package` flag to only build a specific package (the flag can be repeated). However it is superseeded by the `--workspace` flag which effectively instruct to build all packages (not sure if this precedence is a general rule or a positional thing). ### Why it needs to get done While the plugin doesn't explicitely support specifying a package(s), one could abuse the [`rust_cargo_parameters`](https://github.com/canonical/craft-parts/blob/11be8c7a300b28885f9ddcd71f072fae31c440ab/craft_parts/plugins/rust_plugin.py#L50C5-L50C26) to stuff e.g. `['--package', 'foo']`. However, the plugin [hardcode the `--workspace`](https://github.com/canonical/craft-parts/blob/11be8c7a300b28885f9ddcd71f072fae31c440ab/craft_parts/plugins/rust_plugin.py#L316) flag and all packages are built regardless of the workaround. Edit: Similarly, a workspace definition may contain the `default-members` entry. It defines the members of a virtual workspace that should be built in case neither `--workspace` nor `--package` are specified. If `default-members` isn't specified either, the fallback is to build all (`--workspace`). So the hardcoded flag could probably be removed altogether from the plugin. Source: [The cargo book](https://doc.rust-lang.org/cargo/reference/workspaces.html?highlight=workspace#workspaces).

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha
Impact: 35
Quick Win: 21
Complexity: 20
Confidence: 85
Actionability: 75
needs triage Rust plugin hardcodes `cargo build --workspace` in the virtual-workspace branch, so users cannot build a single/selected package; the `rust_cargo_parameters` workaround fails. Still present at HEAD, untriaged and unacknowledged.
qwen/qwen3.6-35b-a3b
Impact: 30
Quick Win: 17
Complexity: 30
Confidence: 80
Actionability: 80
needs triage Rust plugin hardcodes --workspace flag preventing single package builds in virtual workspaces. Issue is open with no labels or maintainer response.
qwen/qwen3.8-27b
Impact: 45
Quick Win: 25
Staleness: 75
Complexity: 45
Confidence: 80
Support Request: 10
needs triage Rust plugin hardcodes --workspace in cargo build for virtual workspaces, blocking single-package builds via --package. Open ~18 months with no maintainer interaction; the hardcoded flag still exists in current code.
qwen/qwen3.6-35b-a3b
Staleness: 92
Complexity: 20
Confidence: 85
Support Request: 10
needs triage Rust plugin hardcodes --workspace in cargo build, blocking single-package builds. Untriaged, no maintainer comments, inactive for over a year.
qwen3.6-35b-a3b-mtp-q6
Staleness: 90
Complexity: 30
Confidence: 75
Support Request: 10
needs triage Rust plugin hardcodes --workspace flag, blocking single-package builds. Unlabelled, zero maintainer comments, inactive for over a year.

Update history

No update history recorded yet.

Related issues

No related issues found above the similarity threshold.