book icon indicating copy to clipboard operation
book copied to clipboard

Cargo update not acting as shown?

Open aronchick 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/book/ch02-00-guessing-game-tutorial.html#updating-a-crate-to-get-a-new-version

Description of the problem: I've been through all the text and I think I'm blind - my Cargo.toml says 0.8.3, and when i run cargo update it just says:

❯ cargo update
    Updating crates.io index
❯ cargo search rand
rand = "0.8.4"              # Random number generators and other randomness functionality. 
[...]
❯ 

Suggested fix: Am I missing something? The Cargo.toml is still reading 0.8.3 too.

aronchick avatar Dec 19 '21 20:12 aronchick

What's in your Cargo.lock file? Because 0.8.3 actually means "any version at least 0.8.3 considered API compatible with 0.8.3", and because rand 0.8.4 is available, you probably got 0.8.4 initially. Cargo.lock records the exact versions that Cargo chose to satisfy the version constrains specified in Cargo.toml.

carols10cents avatar Dec 20 '21 18:12 carols10cents