rust-protobuf
rust-protobuf copied to clipboard
Protobuf Version Mismatch Fix Guide
The error you're encountering is due to a version mismatch between the protobuf crate and the onnx-protobuf crate. Specifically:
- Your project is using
protobufversion 3.5.1 - The
onnx-protobufcrate (version 0.2.3) was compiled againstprotobufversion 3.4.0
This mismatch causes the error:
cannot find value `VERSION_3_4_0` in crate `protobuf`
--> .cargo/registry/src/index.crates.io-6f17d22bba15001f/onnx-protobuf-0.2.3/src/proto/onnx.rs:27:47
|
27 | const _PROTOBUF_VERSION_CHECK: () = protobuf::VERSION_3_4_0;
| ^^^^^^^^^^^^^ help: a constant with a similar name exists: `VERSION_3_5_1`
|
::: target/debug/build/protobuf-9067af482d19c48e/out/version.rs:7:1
|
7 | pub const VERSION_3_5_1: () = ();
| --------------------------- similarly named constant `VERSION_3_5_1` defined here
Resolution Steps
-
Locate the
onnx.rsfile: Path:.cargo/registry/src/index.crates.io-6f17d22bba15001f/onnx-protobuf-0.2.3/src/proto/onnx.rs -
Open
onnx.rsin a text editor. -
Find this line:
const _PROTOBUF_VERSION_CHECK: () = protobuf::VERSION_3_4_0; -
Change it to:
const _PROTOBUF_VERSION_CHECK: () = protobuf::VERSION_3_5_1; -
Save the file.
-
Clean and rebuild your project:
cargo clean cargo build
Important Notes
- This is a temporary fix. The change will be overwritten when you update your dependencies.
- A more permanent solution would involve updating
onnx-protobufto a version compatible withprotobuf3.5.1, or pinningprotobufto version 3.4.0 in yourCargo.toml.
I think this issue should be reported to the authors of the onnx-protobuf crate. The issue doesn't belong to this project.