substrate icon indicating copy to clipboard operation
substrate copied to clipboard

Error during build: failed to run custom build command for sc-network-bitswap

Open revoltez opened this issue 1 year ago • 7 comments

Is there an existing issue?

  • [X] I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • [X] This is not a support question.

Description of bug

Compiling sc-network-bitswap v0.10.0-dev (https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.30#a3ed0119) error: failed to run custom build command for sc-network-bitswap v0.10.0-dev (https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.30#a3ed0119) Caused by: process didn't exit successfully: /home/ezio/Desktop/RustProjects/substrate-node-template/target/release/build/sc-network-bitswap-b1a8656c9520e03c/build-script-build (exit status: 101) --- stdout Running: "/usr/bin/protoc" "--include_imports" "--include_source_info" "-o" "/tmp/prost-buildBdb2Wu/prost-descriptor-set" "-I" "src/schema" "bitswap.v1.2.0.proto"

--- stderr thread 'main' panicked at 'called Result::unwrap() on an Err value: Custom { kind: Other, error: "protoc failed: bitswap.v1.2.0.proto: No such file or directory\n" }', /home/ezio/.cargo/git/checkouts/substrate-7e08433d4c370a21/a3ed011/client/network/bitswap/build.rs:4:58 stack backtrace: 0: rust_begin_unwind at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:584:5 1: core::panicking::panic_fmt at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/panicking.rs:142:14 2: core::result::unwrap_failed at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/result.rs:1814:5 3: core::result::Result<T,E>::unwrap 4: build_script_build::main 5: core::ops::function::FnOnce::call_once note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.

Steps to reproduce

git clone https://github.com/substrate-developer-hub/substrate-node-template
cargo build --release

revoltez avatar Oct 13 '22 14:10 revoltez

Try rm -rf /home/ezio/.cargo/git.

And then try again.

bkchr avatar Oct 13 '22 14:10 bkchr

I ran rm -rf /home/ezio/.cargo/git, but it didn't solve the problem. I proposed a pr #12494 to solve this problem.

anonymousGiga avatar Oct 14 '22 01:10 anonymousGiga

Could this be an issue with your version of protoc? I'm running version 3.21.7 and it works fine here and our CI is happy as well with whatever version it is running on.

altonen avatar Oct 14 '22 07:10 altonen

Could this be an issue with your version of protoc? I'm running version 3.21.7 and it works fine here and our CI is happy as well with whatever version it is running on.

i have version 3.0.0, installed it by following the instructions from the docs, Debian (linux mint 19.1)

revoltez avatar Oct 14 '22 14:10 revoltez

Try rm -rf /home/ezio/.cargo/git.

And then try again.

didn't work

revoltez avatar Oct 14 '22 14:10 revoltez

I have the same issue, polkadot v0.9.29 compiled just fine on the same machine whilst v0.9.30 fails to compile with exactly same error.

OS is Ubuntu 18.04.6 LTS

gituser avatar Oct 18 '22 10:10 gituser

Cannot confirm. The substrate-node-template repo clearnly builds for me both tags polkadot-v0.9.30 and polkadot-v0.9.29 with the following Rust version on Ubuntu 20.04.4 LTS:

cargo version
cargo 1.64.0 (387270bc7 2022-09-16)

cargo +nightly version
cargo 1.66.0-nightly (b332991a5 2022-10-13)

Maybe try again with updated Rust.

PS: Could be that the needed lib versions are not available on Ubuntu 18.04.6 LTS?

ggwpez avatar Oct 18 '22 16:10 ggwpez

@ggwpez v0.9.29 compilation worked just fine, why the sudden change? I'm using latest rust, I do update it before I build polkadot.

  stable-x86_64-unknown-linux-gnu unchanged - rustc 1.64.0 (a55dd71d5 2022-09-19)
   nightly-x86_64-unknown-linux-gnu updated - rustc 1.66.0-nightly (a24a020e6 2022-10-18) (from rustc 1.66.0-nightly (06f049a35 2022-10-17))

gituser avatar Oct 19 '22 09:10 gituser

@ggwpez it might be some cache issue after all, I've tried multiple times rolling back to v0.9.29, building, then building v0.9.30 and then issuing cargo clean and building again v0.9.30 and compilation worked.

Very strange indeed, but the issue is still there somehow.

gituser avatar Oct 19 '22 13:10 gituser

getting same error when trying to build v0.9.31:

Compiling names v0.13.0
error: failed to run custom build command for `sc-network-bitswap v0.10.0-dev (https://github.com/paritytech/substrate?branch=polkadot-v0.9.31#7a4e5163)`

Caused by:
  process didn't exit successfully: `/home/build/polkadot/source/target/release/build/sc-network-bitswap-5bd8ccf92111e3c9/build-script-build` (exit status: 101)
  --- stdout
  Running: "/usr/bin/protoc" "--include_imports" "--include_source_info" "-o" "/tmp/prost-buildz8hZWo/prost-descriptor-set" "-I" "src/schema" "bitswap.v1.2.0.proto"

  --- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Custom { kind: Other, error: "protoc failed: bitswap.v1.2.0.proto: No such file or directory\n" }', /home/build/.cargo/git/checkouts/substrate-7e08433d4c370a21/7a4e516/client/network/bitswap/build.rs:4:58
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace```

gituser avatar Nov 04 '22 13:11 gituser

We fixed this on master.

bkchr avatar Nov 04 '22 13:11 bkchr

@bkchr how do I compile v0.9.31 with master branch of substrate? and why not push this commit to polkadot-v0.9.31 branch?

gituser avatar Nov 04 '22 13:11 gituser

@gituser that doesn't work. You could try to delete your target directory and try to build again. That sometimes fixes it.

bkchr avatar Nov 04 '22 22:11 bkchr

@bkchr that didn't help

gituser avatar Nov 05 '22 11:11 gituser

@bkchr is there any way to apply that fix without creating a fork of this repository and changing dependencies somehow in the build process?

it seems cargo makes a fresh git checkout of substrate repo every time i try to build polkadot.

for others having this issue:

  • first run cargo build --release

  • then find in the logs error regarding sc-network-bitswap and relevant file, e.g. /home/build/.cargo/git/checkouts/substrate-7e08433d4c370a21/a3ed011/client/network/bitswap/build.rs, edit this file according to https://github.com/paritytech/substrate/pull/12494/files change const PROTOS: &[&str] = &["bitswap.v1.2.0.proto"]; to const PROTOS: &[&str] = &["src/schema/bitswap.v1.2.0.proto"];

  • remove cache of the sc-network-bitswap build:

rm -rf /home/build/polkadot/source/target/release/build/sc-network-bitswap-*/*
  • now run cargo build --release --offline
  • enjoy built polkadot

Hopefully this fix will land in polkadot v0.9.32 soon.

gituser avatar Nov 09 '22 11:11 gituser

@bkchr is there any way to apply that fix without creating a fork of this repository and changing dependencies somehow in the build process?

Not that easily. Sorry for the problems! It will land in 0.9.33.

bkchr avatar Nov 09 '22 11:11 bkchr

@bkchr is there any way to apply that fix without creating a fork of this repository and changing dependencies somehow in the build process?

Not that easily. Sorry for the problems! It will land in 0.9.33.

I've already found the solution, see my updated comment: https://github.com/paritytech/substrate/issues/12493#issuecomment-1308592418

gituser avatar Nov 09 '22 11:11 gituser