Skip to content

Support packaging workspaces

Tor Hovland edited this page May 10, 2024 · 14 revisions

cargo package --workspace and cargo publish --workspace won't do what you expect when run on a fresh workspace that hasn't been published before. For any inter-workspace dependencies, Cargo expects to be able to pull down the dependent crate from the registry, ignoring any path dependency. See https://github.com/rust-lang/cargo/issues/10948.

@jneem and @torhovland are trying to fix this issue. It is part of a bigger issue: https://github.com/rust-lang/cargo/issues/1169. If all goes well, we'll proceed with other tasks there.

Our work is in this branch: https://github.com/tweag/cargo/tree/package-workspace.

How to reproduce the issue

cargo test package_workspace

Solution strategy

Change the packaging procedure to something like this:

  1. Determine all intra-workspace path dependencies.
  2. Package each crate using the existing code (without trying to compile/build it).
  3. Unpack all packaged crates in a temporary directory, giving each one a random dir name.
  4. Go through all workspace dependencies from step 1 and fix them up in each crate.
  5. See if this builds.
Clone this wiki locally