cargo build
Updating crates.io index
error: failed to select a version for `protobuf`.
... required by package `tensorflow v0.16.0`
... which is depended on by `test v0.1.0`
versions that meet the requirements `=2.17.0` are: 2.17.0
all possible versions conflict with previously selected packages.
previously selected package `protobuf v2.22.1`
... which is depended on by `rust_tokenizers v6.2.3`
... which is depended on by `test v0.1.0`
failed to select a version for `protobuf` which could resolve this conflict
I understand, that two crates depend on different versions of the same third crate, but I'm not sure what to do next, is this kind of issue cargo cannot handle at all? Are there any workarounds?
Would appreciate any help.
Normally cargo will deal with these sorts of version conflicts by trying hard to find a common version, falling back to compiling both crates separately. However in this case, the tensorflow crate requires exactlyv2.17.0 of protobuf while rust_tokenizers requires something compatible with v2.22.1 (i.e. something greater or equal to 2.22.1 and less than 3.0).
The ideal solution is to create an issue against the tensorflow crate and ask them to create a new release which relaxes their requirements (i.e. remove this "=") so cargo can choose a compatible version.
Normally you wouldn't run into issues like this because libraries should aim to be flexible in which dependency versions they require.
There are also ways of overriding dependencies, but that's mainly used as a temporary mechanism during development (e.g. you forked the tensorflow crate and want to use your version while waiting for the PR to merge) or as an escape hatch/quick hack if you just want to force things to work.
Thanks, Michael!
So, do I understand correctly, asking tensorflow folks to update their dep definition is the only option I have? Could playing with [patch] help here somehow? I don't think I have enough rust/cargo knowledge yet to figure out how I'd use it to resolve this issue