Cargo: [Request] Support shared dependency declaration in virtual manifests

Created on 3 May 2018  路  2Comments  路  Source: rust-lang/cargo

Given a virtual manifest like so:

[workspace]
members = [
    "a",
    "b",
    "c",
    "d",
]

It would be useful to declare dependencies that are shared between members in a central place (such as this manifest):

[dependencies]
serde = "1.0.45"
serde_json = "1.0.17"
serde_derive = "1.0.45"

When building if we are looking for crate serde in, for example, package a but a/Cargo.toml @ dependencies does not list serde we would look in the virtual manifest that includes a as a member (if there is one).


This will no doubt complicate dependency resolution somewhat but I do not know to what extent so if it is too crazy please feel free to close this ticket.


The idea for this is that, at least in my experience, workspace members have certain shared deps that you want to stay in sync and this makes that easier to express.

A-crate-dependencies A-workspaces C-feature-request

Most helpful comment

For anyone interested in this issue I've posted an RFC which I think will help resolve this. Feedback on the RFC would be most welcome!

All 2 comments

I also think that this feature would be really nice to have in Cargo.

More motivation

Imagine if your workspace have... lets say... 20 projects inside it. All of them with the same core 10 dependencies. What if you want to ensure all of your workspace projects use the same version? What if you want to upgrade the version of one of them, include another one or remove some of them?

Some key things to have in mind about it

  • What if you want a specific project to override one of that version? (is it possible? would it potentially break code or cause misterious incompatibilities if linked with other binaries?)
  • What if you want a specific project to exclude some dependencies declared at workspace?
  • What if you want to share other things that are not dependencies (like just properties or other metadata)?

For anyone interested in this issue I've posted an RFC which I think will help resolve this. Feedback on the RFC would be most welcome!

Was this page helpful?
0 / 5 - 0 ratings