Publishing workspace crates

I've been reading Cargo Workspaces - The Rust Programming Language and I have a question. I have used workspaces plenty of times for my own internal/unpublished projects, but I have never published a workspace'd crate.

From the aforementioned page:

If you publish the crates in the workspace to, each crate in the workspace will need to be published separately.

As far as I can understand, one of the points of workspaces is to allow using workspace-relative crates such as foo = { path = "../foo" }, but publishing a crate with a relative dependency seems like a bad idea .. unless, of course, publishing a crate within a workspace always uploads the entire workspace, and the reason one needs to publish each crate is to basically create some kind of "anchor" which will actually index as a crate.

So basically my question is: Is that how it works? Does publishing a crate within a workspace cause the entire workspace to be uploaded [so that relative dependencies get properly resolved]?

  • cargo publish works on individual packages only, not a workspace. The package must be valid considered by itself...
  • ...but the dependency paths will be stripped out of your Cargo.toml along the way.

So, path applies only inside your workspace. When you upload, it becomes a regular dependency that will be resolved by looking at This means that

  • You need a version in the dependency declaration, not just a path.
  • You must publish the packages in dependency order — foo before anything that depends on foo.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.