Cargo book should probably mention that [patch] section doesn't apply to workspace members
Gozala opened this issue · 5 comments
I have spend hours trying to figure out why following step-by-step instructions about working with local dependency changes were not picked up https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#testing-a-bugfix
Turns out it was because [patch] section in workspace members is ignored.
P.S.: It seems that cargo typically warns you about that, however it did not seemed to do it until I did cargo clean
.
Cargo should have warned you with a warning like:
warning: patch for the non root package will be ignored, specify patch at the workspace root:
That should happen with any build command.
BTW, it seems like this should be filed at https://github.com/rust-lang/cargo/issues?
Oh sorry I was not clear. I meant to suggest that it would be great if cargo book mentioned that [patch]
section.
I'm still a bit confused. The Cargo book talks about the [patch]
section here: https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section. It looks like it doesn't mention the workspace restriction, so it probably should. Is that what you are referring to?
This repository is for the edition guide (https://doc.rust-lang.org/stable/edition-guide/). It has a brief blurb about [patch]
(Replacing dependencies with patch), which links to the Cargo book. The edition guide isn't intended to be exhaustive, it just introduces new things between editions with links to the actual documentation.
I'm still a bit confused. The Cargo book talks about the [patch] section here: https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section. It looks like it doesn't mention the workspace restriction, so it probably should. Is that what you are referring to?
Yes
This is where most google searches land
https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
And repeating all the steps leads to surprising behavior if used on workspace member. So it would be great if that document had a note to save others running into confusion I’ve ran.
Please file this bug against cargo/cargo, that's where bugs for the cargo book lives. Thank you!