Failed to build with prost 0.10
remoun opened this issue · 3 comments
remoun commented
Describe the bug
Attempting to use grpcio 0.10
+ grpcio-compiler 0.10
with prost 0.10
fails to build.
IIUC it's because of grpcio
's dependency on prost 0.9
To Reproduce
Steps to reproduce the behavior:
- Make a new crate and add the following deps:
[dependencies] grpcio = { version = "0.10", default-features = false, features = ["prost-codec"] } prost = "0.10" [build-dependencies] grpcio-compiler = { version = "0.10", default-features = false, features = ["prost-codec"] }
- Add a
.proto
file and a build script that generates Rust code viagrpcio_compiler::prost_codegen::compile_protos
- Observe error:
error[E0277]: the trait bound `HealthCheckResponse: prost::message::Message` is not satisfied
--> .../out/protos-auto-gen/grpc.health.v1.rs:40:18
|
40 | ser: ::grpcio::pr_ser,
| ^^^^^^^^^^^^^^^^ the trait `prost::message::Message` is not implemented for `HealthCheckResponse`
|
= help: the following other types implement trait `prost::message::Message`:
()
Box<M>
Vec<u8>
bool
f32
f64
i32
i64
and 4 others
note: required by a bound in `pr_ser`
--> /home/remoun/.cargo/registry/src/github.com-1ecc6299db9ec823/grpcio-0.10.3/src/codec.rs:76:19
|
76 | pub fn ser<M: Message>(msg: &M, buf: &mut GrpcSlice) -> Result<()> {
| ^^^^^^^ required by this bound in `pr_ser`
error[E0277]: the trait bound `HealthCheckResponse: prost::message::Message` is not satisfied
--> .../out/protos-auto-gen/grpc.health.v1.rs:41:17
|
41 | de: ::grpcio::pr_de,
| ^^^^^^^^^^^^^^^ the trait `prost::message::Message` is not implemented for `HealthCheckResponse`
|
= help: the following other types implement trait `prost::message::Message`:
()
Box<M>
Vec<u8>
bool
f32
f64
i32
i64
and 4 others
note: required by a bound in `pr_de`
--> /home/remoun/.cargo/registry/src/github.com-1ecc6299db9ec823/grpcio-0.10.3/src/codec.rs:94:18
|
94 | pub fn de<M: Message + Default>(mut reader: MessageReader) -> Result<M> {
| ^^^^^^^ required by this bound in `pr_de`
Expected behavior
Build succeeds.
System information
- CPU architecture: x86_64
- Distribution and kernel version:
uname -a
output:Linux remoun-mc 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
- SELinux on?: I don't think so
- Any other system details we should know?: I'm running WSL2, but I expect that doesn't matter here.
Additional context
I verified the generated struct includes derive(Message)
:
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct HealthCheckResponse {
#[prost(enumeration = "health_check_response::ServingStatus", tag = "1")]
pub status: i32,
}
So I'm pretty sure it's because of grpcio
's dependency on prost 0.9
CherishCai commented
I have the same problem, how can I solve it temporarily? After MR, it has not been marked as a new crates. Thanks~
Cargo.toml
[dependencies]
thiserror = "1.0"
tokio = { version = "1.21", features = ["full"] }
tokio-stream = { version = "0.1", features = ["net"] }
futures = "0.3"
grpcio = { version = "0.10", default-features = false, features = ["prost-codec"] }
prost = "0.10"
prost-types = "0.10"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
lazy_static = "1.4"
tracing = "0.1"
[build-dependencies]
grpcio-compiler = { version = "0.10", default-features = false, features = ["prost-codec"] }
prost-build = "0.10"
BusyJay commented
I will release a new version this weekend.
CherishCai commented
dependency prot=0.9 works fine for me.
[dependencies]
anyhow = { version = "1", default-features = false, features = ["std"] }
thiserror = "1.0"
tokio = { version = "1.21", features = ["full"] }
tokio-stream = { version = "0.1", features = ["net"] }
futures = "0.3"
grpcio = { version = "0.10", default-features = false, features = ["prost-codec"] }
prost = "0.9"
prost-types = "0.9"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
lazy_static = "1.4"
tracing = "0.1"
[build-dependencies]
grpcio-compiler = { version = "0.10", default-features = false, features = ["prost-codec"] }
prost-build = "0.9"