protoc failed: file contains proto3 optional fields, but --experimental_allow_proto3_optional was not set

Ashutosh SharmaAshutosh Sharma
1 min read

Fixes available online suggested modifying the code in libraries that I did not have access to.

So how to fix this issue without modifying any code?

  1. remove current protobuf compiler:
    sudo apt remove protobuf-compiler
    
  2. install older version (protoc-27.3 worked for me):
    curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v27.3/protoc-27.3-linux-x86_64.zip
    unzip protoc-27.3-linux-x86_64.zip -d /usr/local
    chmod +x /usr/local/bin/protoc
    
0
Subscribe to my newsletter

Read articles from Ashutosh Sharma directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ashutosh Sharma
Ashutosh Sharma

https://github.com/Ashu999