Open msirringhaus opened 3 months ago
Thanks for the report! And really sorry for the late response.
Haven't got more time looking into this, but found more inconsistencies:
vendor --manifest-path wardstone/Cargo.toml --sync rkv/Cargo.toml # ❌
vendor --manifest-path wardstone/Cargo.toml --sync cbindgen/Cargo.toml # ✅
vendor --manifest-path cbindgen/Cargo.toml --sync wardstone/Cargo.toml # ❌
vendor --manifest-path cbindgen/Cargo.toml --sync rkv/Cargo.toml # ✅
Though, the errors from above are different from the “current package believes it's in a workspace” one. It might be that the paths were not normalized (not calling paths::normalize
), so the comparison failed. I forgot the reason Cargo chose not to normalize paths for workspace members.
or it should also work with repos using workspaces.
I feel like this should be supported.
Problem
cargo vendor
fails, if it is called from inside a repository, and--sync
is used to point to another repository outside. This only fails, if one of the repos is using a workspace, while it works if no workspace is present.As examples, I used these three small crates to reproduce: cbindgen, rkv, and wardstone. Only wardstone uses a workspace.
The error-message is
Steps
mkdir sources && cd sources
git clone https://github.com/mozilla/cbindgen && git clone https://github.com/mozilla/rkv && git clone https://github.com/tshakalekholoane/wardstone
Vendoring
rkv
+cbindgen
from inside./rkv
works fine. But vendoringrkv
+wardstone
only works from the top-level dir, and fails otherwise.Possible Solution(s)
cargo vendor
bails in these two functions: https://github.com/rust-lang/cargo/blob/master/src/cargo/core/workspace.rs#L840-L841 (self.error_if_manifest_not_in_members()
only, ifself.validate_members()
is commented out, obviously).That function doesn't distinguish between vendoring and other operations.
Notes
I am not 100% certain, if this is a bug or expected behavior. But I do feel that the results are inconsistent. Either
--sync
should never allow to vendor from inside a repository, or it should also work with repos using workspaces.I'd be willing to look into this, once it's clear what the desired behavior is.
Version