hyperium / tonic

A native gRPC client & server implementation with async/await support.
https://docs.rs/tonic
MIT License
10.1k stars 1.02k forks source link

Hello world example does not compile #1537

Open GaelicGabe opened 1 year ago

GaelicGabe commented 1 year ago

Bug Report

Version

Latests master on github

Platform

Linux dev-fedora 6.1.43-1.qubes.fc32.x86_64

Description

I did the following git clone https://github.com/hyperium/tonic.git cd tonic/examples cargo build --bin helloworld-server and then I get the following error:

   Compiling examples v0.1.0 (/home/user/dev/experiments/tonic/examples)
error: failed to run custom build command for `examples v0.1.0 (/home/user/dev/experiments/tonic/examples)`

Caused by:
  process didn't exit successfully: `/home/user/dev/experiments/tonic/target/debug/build/examples-e0eba3978652fe71/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=proto/routeguide/route_guide.proto
  cargo:rerun-if-changed=proto
  cargo:rerun-if-changed=proto/helloworld/helloworld.proto
  cargo:rerun-if-changed=proto
  cargo:rerun-if-changed=proto/echo/echo.proto
  cargo:rerun-if-changed=proto/echo
  cargo:rerun-if-changed=proto/unaryecho/echo.proto
  cargo:rerun-if-changed=proto/unaryecho
  cargo:rerun-if-changed=proto/attrs/attrs.proto
  cargo:rerun-if-changed=proto
  cargo:rerun-if-changed=proto/googleapis/google/pubsub/v1/pubsub.proto
  cargo:rerun-if-changed=proto/googleapis

  --- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Custom { kind: Other, error: "protoc failed: google/protobuf/descriptor.proto: File not found.\ngoogle/api/annotations.proto:20:1: Import \"google/protobuf/descriptor.proto\" was not found or had errors.\ngoogle/api/annotations.proto:28:8: \"google.protobuf.MethodOptions\" is not defined.\ngoogle/api/client.proto:19:1: Import \"google/protobuf/descriptor.proto\" was not found or had errors.\ngoogle/api/client.proto:27:8: \"google.protobuf.MethodOptions\" is not defined.\ngoogle/api/client.proto:66:8: \"google.protobuf.ServiceOptions\" is not defined.\ngoogle/api/client.proto: \"google.protobuf.ServiceOptions\" is not defined.\ngoogle/api/field_behavior.proto:19:1: Import \"google/protobuf/descriptor.proto\" was not found or had errors.\ngoogle/api/field_behavior.proto:27:8: \"google.protobuf.FieldOptions\" is not defined.\ngoogle/api/resource.proto:19:1: Import \"google/protobuf/descriptor.proto\" was not found or had errors.\ngoogle/api/resource.proto:28:8: \"google.protobuf.FieldOptions\" is not defined.\ngoogle/api/resource.proto:34:8: \"google.protobuf.FileOptions\" is not defined.\ngoogle/api/resource.proto:40:8: \"google.protobuf.MessageOptions\" is not defined.\ngoogle/protobuf/duration.proto: File not found.\ngoogle/protobuf/empty.proto: File not found.\ngoogle/protobuf/field_mask.proto: File not found.\ngoogle/protobuf/timestamp.proto: File not found.\ngoogle/pubsub/v1/schema.proto:19:1: Import \"google/api/annotations.proto\" was not found or had errors.\ngoogle/pubsub/v1/schema.proto:20:1: Import \"google/api/client.proto\" was not found or had errors.\ngoogle/pubsub/v1/schema.proto:21:1: Import \"google/api/field_behavior.proto\" was not found or had errors.\ngoogle/pubsub/v1/schema.proto:22:1: Import \"google/api/resource.proto\" was not found or had errors.\ngoogle/pubsub/v1/schema.proto:23:1: Import \"google/protobuf/empty.proto\" was not found or had errors.\ngoogle/pubsub/v1/schema.proto:70:50: \"google.protobuf.Empty\" is not defined.\ngoogle/pubsub/v1/pubsub.proto:19:1: Import \"google/api/annotations.proto\" was not found or had errors.\ngoogle/pubsub/v1/pubsub.proto:20:1: Import \"google/api/client.proto\" was not found or had errors.\ngoogle/pubsub/v1/pubsub.proto:21:1: Import \"google/api/field_behavior.proto\" was not found or had errors.\ngoogle/pubsub/v1/pubsub.proto:22:1: Import \"google/api/resource.proto\" was not found or had errors.\ngoogle/pubsub/v1/pubsub.proto:23:1: Import \"google/protobuf/duration.proto\" was not found or had errors.\ngoogle/pubsub/v1/pubsub.proto:24:1: Import \"google/protobuf/empty.proto\" was not found or had errors.\ngoogle/pubsub/v1/pubsub.proto:25:1: Import \"google/protobuf/field_mask.proto\" was not found or had errors.\ngoogle/pubsub/v1/pubsub.proto:26:1: Import \"google/protobuf/timestamp.proto\" was not found or had errors.\ngoogle/pubsub/v1/pubsub.proto:27:1: Import \"google/pubsub/v1/schema.proto\" was not found or had errors.\ngoogle/pubsub/v1/pubsub.proto:159:3: \"Encoding\" is not defined.\ngoogle/pubsub/v1/pubsub.proto:230:3: \"google.protobuf.Timestamp\" is not defined.\ngoogle/pubsub/v1/pubsub.proto:261:3: \"google.protobuf.FieldMask\" is not defined.\ngoogle/pubsub/v1/pubsub.proto:692:3: \"google.protobuf.Duration\" is not defined.\ngoogle/pubsub/v1/pubsub.proto:760:3: \"google.protobuf.Duration\" is not defined.\ngoogle/pubsub/v1/pubsub.proto:764:3: \"google.protobuf.Duration\" is not defined.\ngoogle/pubsub/v1/pubsub.proto:809:3: \"google.protobuf.Duration\" is not defined.\ngoogle/pubsub/v1/pubsub.proto:919:3: \"google.protobuf.FieldMask\" is not defined.\ngoogle/pubsub/v1/pubsub.proto:1192:3: \"google.protobuf.FieldMask\" is not defined.\ngoogle/pubsub/v1/pubsub.proto:1225:3: \"google.protobuf.Timestamp\" is not defined.\ngoogle/pubsub/v1/pubsub.proto:1304:5: \"google.protobuf.Timestamp\" is not defined.\ngoogle/pubsub/v1/pubsub.proto:118:48: \"google.protobuf.Empty\" is not defined.\ngoogle/pubsub/v1/pubsub.proto:463:16: \"google.protobuf.Empty\" is not defined.\ngoogle/pubsub/v1/pubsub.proto:476:16: \"google.protobuf.Empty\" is not defined.\ngoogle/pubsub/v1/pubsub.proto:492:48: \"google.protobuf.Empty\" is not defined.\ngoogle/pubsub/v1/pubsub.proto:529:16: \"google.protobuf.Empty\" is not defined.\ngoogle/pubsub/v1/pubsub.proto:607:54: \"google.protobuf.Empty\" is not defined.\n" }', examples/build.rs:33:10

If I remove the following lines from examples/build.rs it works again

    tonic_build::configure()
        .build_server(false)
        .compile(
            &["proto/googleapis/google/pubsub/v1/pubsub.proto"],
            &["proto/googleapis"],
        )
        .unwrap();
fmartinsons commented 1 year ago

Hello, did you try re-installing the protoc package ? moreover can you specify the tonic commit you tried, telling "current master" is not enough.

seanlossef-kce commented 8 months ago

I am having the same issue. I have a fresh install of protoc running on version v0.11.0 of tonic (https://github.com/hyperium/tonic/releases/tag/v0.11.0).

inevity commented 8 months ago

When in protoc 25.1 on arch , build ok. when protoc 3.14.0 on rockylinux, same issue. Now just workaround as above remove line.

mxtm commented 8 months ago

I am having this issue with protoc 3.19.6 and tonic 0.9 on Fedora 39.

Commands in the description give me the same error

Yingming29 commented 4 months ago

Has someone solved this problem? I also have the issue on protoc 3.12.4.