This is motivated by a discussion at crate-ci/cargo-release#288
Currently, cargo add will
- dep by path: use the path
- dep by name: look up version in crates.io and uses it
For workspaces, users generally want
- always use path dependency
- If crate being modified is publishable and the dependency is non-dev, use the version that is currently in the workspace
I propose we change cargo add to:
- If user specifies
name@ver, name-as-uri, --git, or --ver, --path, process as we do today
- If
name is in workspace (either as path or name),
- always use path dependency
- If crate being modified is publishable and the dependency is non-dev, use the version that is currently in the workspace
For the rare times this isn't the desired behavior, it would be relatively trivial for users to adjust. However, knowing the best practice for adding a workspace dep for new users is tricky
- With
cargo-release, we've seen people use [patch] because it was the first way they discovered doing this
- It requires hand copying the version over when specifying path
- The version is flat out wrong when just specifying a name
- Its not obvious that
dev-dependency doesn't need version which is important when there are test cycles
This is motivated by a discussion at crate-ci/cargo-release#288
Currently,
cargo addwillFor workspaces, users generally want
I propose we change
cargo addto:name@ver,name-as-uri,--git, or--ver,--path, process as we do todaynameis in workspace (either as path or name),For the rare times this isn't the desired behavior, it would be relatively trivial for users to adjust. However, knowing the best practice for adding a workspace dep for new users is tricky
cargo-release, we've seen people use[patch]because it was the first way they discovered doing thisdev-dependencydoesn't need version which is important when there are test cycles