Ran into a weird Protobuf issue when compiling the...
# development
b
Ran into a weird Protobuf issue when compiling the Rust part of the Pants codebase - curious if anyone else has run into this:
Copy code
--- stderr
  Error: Custom { kind: Other, error: "protoc failed: google/bytestream/bytestream.proto: warning: Import google/protobuf/wrappers.proto but not used.\ncache.proto:39:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default.\n" }
1
I can of course edit the
cache.proto
file to fix this, but I’m curious if I did something stupid like install the wrong version of protobuf
protoc
version:
Copy code
protoc --version

libprotoc 3.6.1
c
I had the same problem! and bisected to https://github.com/pantsbuild/pants/commit/1ec5fea40bc51ee6195fad0fc9cb185aea0cc335 but my protoc was apparently some random(!?) binary in
~/bin
, and it worked after I got rid of that. (For reasons relating to my not knowing rust at all, just deleting
optional
was not enough.)
d
proto3 originally got rid of the optional keyword, but they added it back in version 3.15 https://github.com/protocolbuffers/protobuf/releases/tag/v3.15.0
that was released in 2021 🙂
b
Huh okay, thanks! It doesn’t look like I have that protoc problem:
Copy code
which protoc
/usr/bin/protoc
And good to know, thanks @dazzling-pizza-75442 - guess I’ll have to install protoc from source 😱
d
... or figure out how to add that flag to the protoc invocation...
--experimental_allow_proto3_optional
b
Managed to get around this by installing protoc directly from GitHub releases: https://github.com/protocolbuffers/protobuf/releases Thanks everyone for the help!
👍🏻 1