3

When building a Substrate-project, I receive the following error: protoc failed: bitswap.v1.2.0.proto: No such file or directory

1 Answer 1

0

Most likely your protobuf-compiler version is outdated.

Starting from Substrate dependency version polkadot-v0.9.32, the 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:

  1. Remove protobuf-compiler: sudo apt remove protobuf-compiler
  2. Use temporary folder: tmp_folder="/tmp/proto-$RANDOM" && mkdir -p "$tmp_folder" && pushd "$tmp_folder" > /dev/null
  3. Download a recent version of Protobuf from the official repository (the following version was tested): wget https://github.com/protocolbuffers/protobuf/releases/download/v23.3/protoc-23.3-linux-x86_64.zip
  4. Unpack protoc from zip file: unzip protoc-23.3-linux-x86_64.zip bin/protoc
  5. Move protoc into binary folder: sudo cp -r ./bin/ /usr
  6. Move back to starting point: popd > /dev/null
  7. (Optional when using /tmp) Clean up: rm -r "$tmp_folder"
  8. Verify that protobuf-compiler was installed and can be located: protoc --version (should emit "libprotoc 23.3" in this case)

All-in-one command:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.