book icon indicating copy to clipboard operation
book copied to clipboard

Ch14.03 Unclear description of dependency versions across a workspace

Open tpdickson opened this issue 3 years ago • 1 comments

  • [x] I have checked the latest main branch to see if this has already been fixed
  • [x] I have searched existing issues and pull requests for duplicates

URL to the section(s) of the book with this problem: https://doc.rust-lang.org/stable/book/ch14-03-cargo-workspaces.html#depending-on-an-external-package-in-a-workspace

Description of the problem: The book states that the top-level Cargo.lock file in a workspace ensures that all crates in the workspace use the same version of dependencies. It uses the crate rand as an example. It further states the same thing again, and that "no additional copies of rand will be downloaded." I've set the adder crate to use rand 0.7.3 and the add_one crate to use rand 0.8.3, then built the workspace. In my workspace's Cargo.lock file, there is now rand 0.7.3 and rand 0.8.5, and the output log on cargo build showed that it compiled the second version of rand.

Suggested fix: The current text is either not clear enough to describe how dependency versioning is handled within a workspace, or the description is incorrect. I don't know what the correct behavior should be, but what I'm seeing from my workspace is contradicting what I'm reading in the book.

tpdickson avatar May 05 '22 16:05 tpdickson

Yeah, it seems that dependencies in the same workspace can have different versions.

zetaraku avatar Jul 21 '23 07:07 zetaraku