Why can't I run cargo update?

All I'm doing is this command

cargo update -p wasm-bindgen --precise 0.2.106

my Cargo.toml has the dependencies as

wasm-bindgen = "=0.2.105"

The error whenever i run the command is as follows

error: failed to select a version for the requirement `wasm-bindgen = "=0.2.105"`
candidate versions found which didn't match: 0.2.106
location searched: crates.io index
required by package `myapp v0.1.0 (C:\Users\myname\myapp)` 
1 Like

cargo update only changes the lock file, but your manifest is pinning a specific version, so it can't update to anything else.

3 Likes

It's because you have in your Cargo.toml,
wasm-bindgen = "=0.2.105"

This forbids any other version of wasm-bindgen apart from exactly 0.2.105
Either just remove the "=" or change it to "=0.2.106" and it will work.

This is actually a more concise and correct explanation :'D

1 Like

As @cuviper pointed out, cargo update works on the lock file Cargo.lock.

For checking Cargo.toml there are additional tools available, like cargo-upgrades.

2 Likes

You may also relax the version constraints to "0.2" or "0" respectively. See semver.org for the semantics.

1 Like