Description
My team has a small project that depends on avro-rs
(0.7.0) and schema_registry_converter
(1.1.0)[which itself depends on avro-rs
]. Recently, a team member cloned the repo for the first time, tried to compile, and was met with the E0308
error pointing at the use of avro_rs::types::Value
; saying it expected a reference of that type but found a reference of the same type with the note: "perhaps two different versions of crate avro-rs
are being used?"
I had them install and run cargo-tree
to see what version of avro-rs
their schema_registry_converter
was using as I couldn't reproduce the issue and mine was using 0.7.0. They noted that it was using 0.9.0, and that changing our avro-rs
dependency to 0.9.0 fixed the build issue (which makes sense). Curious as to why our dependencies differed, I checked crates.io and it said that schema_registry_converter
was last updated 10 months ago so there's no way my teammate could have moved to a new version. However, I noticed in their Cargo.toml file that the avro-rs
version is set to >= 0.6.0.
Correct me if I'm wrong, but my assumption is that, when a dependency is set like so, and there's no cached version, cargo will pull the latest version for compilation. I then tried changing my own avro-rs
dependency from 0.7.0 to 0.9.0 and the build failed with the same issue, but I was able to resolve it by clearing the cached dependencies and rebuilding.
I guess my problem/issue/question is, what needs to be done so that we don't encounter this issue when avro-rs
updates again? Obviously, we can just update our dependency, but it seems like a waste of time to either keep an eye on the avro-rs
crate for updates, or wait for a build to fail. I believe we could clone schema_registry_converter
and set the avro-rs
version ourselves, but that seems like a hacky workaround?
Also, is there a reason that cargo doesn't take other dependencies into consideration during the build step? What I mean is, in this instance avro-rs
gets pulled and compiled before schema_registry_converter
; why does crate not see that instance of avro-rs
while it's compiling schema_registry_converter
then check the version and see if it's usable before pulling it's own dependency?