neoeinstein / protoc-gen-prost

Apache License 2.0
150 stars 43 forks source link

How to deal with error "could not find `protobuf` in `super`" on the NullValue? #111

Closed liufuyang closed 17 hours ago

liufuyang commented 19 hours ago

I have this example repo here for repeat https://github.com/liufuyang/rust-buf-bigtable-test

Basically, the generation works, but when cargo build, it gives error:

error[E0433]: failed to resolve: could not find `protobuf` in `super`
   --> src/gen/google.api.expr.v1alpha1.serde.rs:319:108
    |
319 | ...ption<super::super::super::protobuf::NullValue>>()?.map(|x| constant::ConstantKind::NullValue(x as ...
    |                               ^^^^^^^^ could not find `protobuf` in `super`

There seems to be a pbjson_types::NullValue available, but the generated code could not use it?

Thanks.

neoeinstein commented 18 hours ago

Because this is a bit of a special case, where you're generating inside the google package, it's assuming that protobuf will also be in that crate. Have you tried adding an extern_path directive to the serde invocation, like you have for Tonic and Prost?

liufuyang commented 17 hours ago

oh thanks, well, that seems does the trick, thanks a lot :)