-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
Problem
We are using a workspace to centrally managed certificate configuration including dependencies. This makes it easier to ship some - perhaps all - workspace packages on separate schedules with approved dependency versions (likely the latest minor or patch version). Unfortunately, cargo add - which we expect most crate developers will use - cannot add a dependency to a workspace.
If our workspace is Cargo.toml and member crates are under sdk/ e.g., sdk/core/Cargo.toml, what should happen somehow is:
- The dependency and any enabled features are added to the workspace
Cargo.tomlunder[workspace.dependencies]. - An inherited dependency i.e.,
name = { workspace = inherit }is added to whatever dependency section is chosen e.g.,[workspace]by default or[dev-dependencies]when--devis specified.
Proposed Solution
Ideally, cargo add just works without additional command line switches. This makes it easier in a monorepo with many different contributing teams that don't have to think about different paradigms than they are used to. Perhaps some configuration in .cargo/config.toml e.g.,
[dependencies]
inherit = trueIf lieu of or even in addition to, it seems that cargo add {dependency} --package {package} --manifest-path {workspace cargo.toml} should do this. Currently it does not, and seems to ignore the --manifest-path. If I don't use --package and use just --manifest-path, I get an error:
error: `cargo add` could not determine which package to modify. Use the `--package` option to specify a package.
available packages: {package list}
Notes
May be related to #12208.