tonic icon indicating copy to clipboard operation
tonic copied to clipboard

Cannot compile dependency

Open marci1175 opened this issue 1 year ago • 1 comments

Bug Report

Version

└── tonic v0.11.0 └── tonic-build v0.7.2

Platform

Windows 11 64-bit build: 22631.2715

Description

Every time I try to compile tonic, with no features, I am constantly getting build errors Ive tried to fix them by editing the codegen file, which worked but ofcourse every time I reopen vs code the errors re-appear.

I tried to compile the hello world example, but it didnt work. Ive been having this issue since january 7th, there i was using tonic "0.7" and when I added the feature "compression" these problems would appear.

error[E0599]: no method named send_gzip found for struct tonic::client::Grpc in the current scope
  --> C:\Users\marci\Desktop\FileHosting\target\debug\build\FileHosting-878bc6a1594928c5\out/file_hosting.rs:69:37
   |
69 |             self.inner = self.inner.send_gzip();
   |                                     ^^^^^^^^^ method not found in Grpc<T>

error[E0599]: no method named accept_gzip found for struct tonic::client::Grpc in the current scope
  --> C:\Users\marci\Desktop\FileHosting\target\debug\build\FileHosting-878bc6a1594928c5\out/file_hosting.rs:75:37
   |
75 |             self.inner = self.inner.accept_gzip();
   |                                     ^^^^^^^^^^^ method not found in Grpc<T>

error[E0308]: arguments to this method are incorrect
   --> C:\Users\marci\Desktop\FileHosting\target\debug\build\FileHosting-878bc6a1594928c5\out/file_hosting.rs:189:30
    |
189 | ...                   .apply_compression_config(
    |                        ^^^^^^^^^^^^^^^^^^^^^^^^
190 | ...                       accept_compression_encodings,
    |                           ---------------------------- expected EnabledCompressionEncodings, found ()
191 | ...                       send_compression_encodings,
    |                           -------------------------- expected EnabledCompressionEncodings, found ()
    |
note: method defined here
   --> C:\Users\marci\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tonic-0.11.0\src\server\grpc.rs:183:12
    |
183 |     pub fn apply_compression_config(
    |            ^^^^^^^^^^^^^^^^^^^^^^^^

But with the latest version (v0.11.0) I cannot remove this feature I guess.

I edited:

/// The greeting service definition.
    #[derive(Debug)]
    pub struct GreeterServer<T: Greeter> {
        inner: _Inner<T>,
        accept_compression_encodings: (),
        send_compression_encodings: (),
    }

to:

/// The greeting service definition.
    #[derive(Debug)]
    pub struct GreeterServer<T: Greeter> {
        inner: _Inner<T>,
        accept_compression_encodings: EnabledCompressionEncodings,
        send_compression_encodings: EnabledCompressionEncodings,
    }

And also had to bring use tonic::server::NamedService; into scope, but that was in the changleog that I had to do that.

This is my very first issue opened, so Im happy to provide more info if I missed something

marci1175 avatar Feb 22 '24 09:02 marci1175

I believe you need to enable this feature https://github.com/hyperium/tonic/blob/master/tonic/Cargo.toml#L27

LucioFranco avatar Feb 23 '24 18:02 LucioFranco