Given a Cargo workspace in one git repository that contains one crate foo, and another crate bar outside of that workspace, how do I depend on foo in bar? If foo were just a regular crate-within-a-git-repo, the following works:
foo = { git = "ssh://git@server/some/foo.git", ... }
And if foo were inside a Cargo workspace and it lives in a local directory, the following works:
foo = { path = "../../some-workspace/foo" }
But using git = "ssh://..." that points to a repository that contains a Cargo workspace, I am unable to specify the foo crate in particular.
It is not possible to combine git = "..." and path = "...", since those are mutually exclusive.
In the Specifying dependencies from git repositories chapter of The Cargo Book, it offers branch = "...", tag = "...", rev = "...", but no "sub-crate's directory name, i.e. the name of the crate". There is a package = "..." specifier mentioned under Renaming dependencies in Cargo.toml meant for importing a crate as something else. But it doesn't seem to double as the crate-within-a-workspace specifier.
Your dependency name should have the name of the crate in the workspace. Cargo will search for it. Suppose the workspace foo has crate bar within it.
bar = { git = "ssh://git@server/some/foo.git", ... }
Not sure where this is documented, but there is a discussion here:
https://github.com/rust-lang/cargo/issues/10151
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With