Skip to content

fix(external-only): prune feature entries that name a stripped path dependency - #1

Merged
josecelano merged 3 commits into
torrust:patch/external-only-flagfrom
josecelano:fix/external-only-prune-features
Nov 4, 2026
Merged

josecelano merged 3 commits into
torrust:patch/external-only-flagfrom
josecelano:fix/external-only-prune-features

Conversation

@josecelano

Copy link
Copy Markdown
Member

cargo chef prepare --external-only removes path = "..." dependencies from every manifest, but it left the [features] entries that name them. An optional workspace dependency behind a feature is a valid and now planned pattern in torrust/torrust-tracker (testing = ["dep:torrust-tracker-swarm-coordination-registry"], see torrust/torrust-tracker#2711). With the current torrust-cargo-chef 0.1.78 the skeleton manifest is then invalid and cargo chef cook exits with status 101:

failed to load manifest for workspace member `.../packages/udp-server`
  feature `testing` includes `dep:torrust-tracker-swarm-coordination-registry`, but `torrust-tracker-swarm-coordination-registry` is not listed as a dependency

What changes

  • src/skeleton/external_only.rs: after stripping a manifest, prune the [features] entries that name a removed dependency: dep:name, name (the implicit feature of an optional dependency), name/feature and name?/feature. The feature itself is kept, possibly empty, so entries of other features that refer to it stay valid. A plain name that is also the name of a feature is kept (it then refers to the feature). Names removed from top-level, target-specific and workspace = true dependency tables count; [workspace.dependencies] names do not, because no feature can refer to them.
  • Tests first: six unit tests failed before the change (dep: entry, implicit entry, name/feature and name?/feature, workspace = true reference, target-specific dependency, plain entry that names a feature) next to control tests that passed; one skeleton integration test covers the failing shape end to end.
  • CHANGELOG.md and README.md describe the behaviour; the last commit bumps the version to 0.1.79 so the Containerfile of the tracker can pin it.

Verification

  • cargo test passes in the whole crate (18 unit tests in the module, the skeleton and caching integration tests); cargo fmt --check passes. cargo clippy --all-targets -- -D warnings reports one error in src/skeleton/read.rs (useless_borrows_in_formatting), which is also present without this change and is not touched here.
  • On the real tracker tree (branch of refactor(udp-server): [#2699] gate the test environment behind a testing feature torrust-tracker#2711, 2026-11-04 12:12 UTC): torrust-cargo-chef 0.1.78 cargo chef prepare --external-only then cargo chef cook --tests --workspace --all-features exits 101 with the message above; the build of this branch (0.1.79) writes testing = [] in the skeleton of udp-server and the same cook exits 0.

After merging

Tag v0.1.79-torrust and publish torrust-cargo-chef 0.1.79; the tracker then bumps [email protected] in its Containerfile. Rows 4 to 7 of torrust/torrust-tracker#2482 need it.

josecelano and others added 3 commits November 4, 2026 12:11
…ependency

--external-only removed path dependencies from every manifest but left the [features] entries that name them, so an optional workspace dependency behind a feature (testing = ["dep:internal"]) made cargo reject the skeleton manifest and cargo chef cook fail with status 101. Prune dep:name, name, name/feature and name?/feature for the removed dependencies, keep the feature (possibly empty), and keep a plain entry that names an existing feature.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 4, 2026 12:18
@josecelano josecelano self-assigned this Nov 4, 2026
@josecelano

Copy link
Copy Markdown
Member Author

ACK ac66921

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the external-only feature-pruning change.

No open issues 🎉

What changed in this PR

Fixes cargo chef prepare --external-only leaving invalid feature references after removing path dependencies, allowing the resulting skeleton manifests to be used by cargo chef cook.

Changes:

  • Prunes feature entries that reference stripped dependencies while preserving feature definitions and references to explicit features.
  • Adds unit and skeleton integration coverage and documents the behavior.
  • Bumps torrust-cargo-chef to version 0.1.79.
File Description
tests/​skeletons/​tests/​external_only.rs Adds integration coverage for pruning feature references to stripped dependencies.
src/​skeleton/​external_only.rs Tracks removed dependency names, prunes feature references, and adds unit tests.
README.md Documents feature pruning in external-only mode.
CHANGELOG.md Records the invalid-manifest fix.
Cargo.toml Bumps the package version to 0.1.79.
Cargo.lock Updates the locked package version to 0.1.79.

Review effort: Balanced

@josecelano
josecelano merged commit 38f69ee into torrust:patch/external-only-flag Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants