When building a Substrate-project, I receive the following error:
protoc failed: bitswap.v1.2.0.proto: No such file or directory
Most likely your protobuf-compiler version is outdated.
Starting from Substrate dependency version
protobuf-compiler version supplied by the apt repository on Ubuntu 18 or older does not meet the version requirement to build a Substrate project. This can also happen with package managers used by other operating systems.
To resolve on Ubuntu 18 or older:
- Remove protobuf-compiler:
sudo apt remove protobuf-compiler
- Use temporary folder:
tmp_folder="/tmp/proto-$RANDOM" && mkdir -p "$tmp_folder" && pushd "$tmp_folder" > /dev/null
- Download a recent version of Protobuf from the official repository (the following version was tested):
- Unpack protoc from zip file:
unzip protoc-23.3-linux-x86_64.zip bin/protoc
- Move protoc into binary folder:
sudo cp -r ./bin/ /usr
- Move back to starting point:
popd > /dev/null
- (Optional when using
/tmp) Clean up:
rm -r "$tmp_folder"
- Verify that protobuf-compiler was installed and can be located:
protoc --version(should emit "libprotoc 23.3" in this case)
sudo apt remove protobuf-compiler \ && tmp_folder="/tmp/proto-$RANDOM" \ && mkdir -p "$tmp_folder" \ && pushd "$tmp_folder" > /dev/null \ && wget https://github.com/protocolbuffers/protobuf/releases/download/v23.3/protoc-23.3-linux-x86_64.zip \ && unzip protoc-23.3-linux-x86_64.zip bin/protoc \ && sudo cp -r ./bin/ /usr \ && popd > /dev/null \ && rm -r "$tmp_folder" \ && protoc --version