How do you vendor library crate that uses workspaces?

My application has multiple binaries, and multiple libraries, so I created a top level workspace.

|-- Cargo.toml
|-- src
|    |-- bin1 (contains a `Cargo.toml` and rust files)
|    |-- bin2 (contains a `Cargo.toml` and rust files)
|-- lib
     |-- libA (contains a `Cargo.toml` and rust files)
     |-- libB (contains a `Cargo.toml` and rust files)

libA is a library that I wrote, while libB is a library that I cloned from github (I have a few modification that cannot be upstreamed as-it). It works well. My top-level Cargo.toml is:

members = [

But then I wanted to vendor petgraph that itself uses workspace. When I cloned it into the lib directory, and run cargo check from the top-level directory, I got the following error:

error: multiple workspace roots found in the same workspace:

How can I vendor library crates that uses workspace if I'm using workspace myself?

EDIT: I found this issue on nested workspace but I'm even more confused. If I understand correctly it's not possible to have nested workspace?

If you only want to use petgraph as a dependency and not do any development on it, then the easiest solution would be to exclude it from your workspace, and just depend on it your local copy of it via path dependencies or a [patch] section (like the one that the cargo vendor command prints).

If you do plan on doing development within the petgraph crate, then I suggest patching its manifest to remove its [workspace] section, and instead adding its members to your top-level workspace.

I effectively do plan to modify it (otherwise I wouldn't vendor it). I was hopping that I would not need to alter anything (but the think I want to modify obviously) from petgraph, but it seems not possible.

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.