graphprotocol / graph-node

Graph Node indexes data from blockchains such as Ethereum and serves it over GraphQL
https://thegraph.com
Apache License 2.0
2.92k stars 982 forks source link

error: failed to run custom build command for `graph-chain-substreams v0.28.2 (graph-node/chain/substreams) #4168

Open harshchhatbar34 opened 2 years ago

harshchhatbar34 commented 2 years ago

I am trying to run a cargo Build and facing this issue

error: failed to run custom build command for graph-chain-substreams v0.28.2 (/home/harsh/zeeve/GRAPH/graph-node/chain/substreams)

Caused by: process didn't exit successfully: /home/harsh/zeeve/GRAPH/graph-node/target/debug/build/graph-chain-substreams-025de39176fcb4a4/build-script-build (exit status: 101) --- stdout cargo:rerun-if-changed=proto

--- stderr thread 'main' panicked at 'Failed to compile Substreams entity proto(s): Custom { kind: Other, error: "protoc failed: codec.proto:44: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.\ncodec.proto:45: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" }', chain/substreams/build.rs:6:10 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace warning: build failed, waiting for other jobs to finish...

johnmesh commented 2 years ago

I'm having the same issue cargo --version
cargo 1.65.0 (4bc8f24d3 2022-10-20) rustc --version rustc 1.65.0 (897e37553 2022-11-02)

johnmesh commented 2 years ago

adding protoc_arg("--experimental_allow_proto3_optional") in the chain/substreams/build.rs file worked for me

fn main() {
    println!("cargo:rerun-if-changed=proto");
    tonic_build::configure()
        .out_dir("src/protobuf")
        .protoc_arg("--experimental_allow_proto3_optional")
        .compile(&["codec.proto"], &["proto"])
        .expect("Failed to compile Substreams entity proto(s)");
}
ancjf commented 1 year ago

adding protoc_arg("--experimental_allow_proto3_optional") in the chain/substreams/build.rs

The issue remains.

branch v0.29.0-rc.0 cargo 1.65.0 (4bc8f24d3 2022-10-20) rustc 1.65.0 (897e37553 2022-11-02)

error: failed to run custom build command for graph-chain-substreams v0.29.0 (/mnt/c/src/rust/graph-node/chain/substreams)

Caused by: process didn't exit successfully: /mnt/c/src/rust/graph-node/target/debug/build/graph-chain-substreams-0afc3a65ad2b8adf/build-script-build (exit status: 101) --- stdout cargo:rerun-if-changed=proto

--- stderr thread 'main' panicked at 'Failed to compile Substreams entity proto(s): Custom { kind: Other, error: "protoc failed: Unknown flag: --experimental_allow_proto3_optional\n" }', chain/substreams/build.rs:7:10 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

maoueh commented 1 year ago

Seems a recent enough protoc is required.

A more "permanent" fix that we discussed but not implemented yet will be to remove automatic Protobuf codegen and turn that into a manual command.

This means no need to have protoc and all other tooling just to build the binary.

maoueh commented 1 year ago

@ancjf For now, update your protoc to a more recent version.

github-actions[bot] commented 1 year ago

Looks like this issue has been open for 6 months with no activity. Is it still relevant? If not, please remember to close it.