hyperium / hyper

An HTTP library for Rust
https://hyper.rs
MIT License
14.58k stars 1.6k forks source link

v0.14.21 broken build #3038

Closed mskrzypkows closed 2 years ago

mskrzypkows commented 2 years ago

Version v0.14.21

Platform MacOS and Linux

Description

Cannot build the newest hyper:

[2022-10-31T14:18:27.529Z] error[E0599]: no method named `with_interval` found for struct `TcpKeepalive` in the current scope
[2022-10-31T14:18:27.529Z]   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.21/src/server/tcp.rs:49:12
[2022-10-31T14:18:27.529Z]    |
[2022-10-31T14:18:27.529Z] 49 |         ka.with_interval(interval)
[2022-10-31T14:18:27.529Z]    |            ^^^^^^^^^^^^^ method not found in `TcpKeepalive`
[2022-10-31T14:18:27.529Z] 
[2022-10-31T14:18:27.529Z] error[E0599]: no method named `with_retries` found for struct `TcpKeepalive` in the current scope
[2022-10-31T14:18:27.529Z]   --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.21/src/server/tcp.rs:60:12
[2022-10-31T14:18:27.529Z]    |
[2022-10-31T14:18:27.529Z] 60 |         ka.with_retries(retries)
[2022-10-31T14:18:27.529Z]    |            ^^^^^^^^^^^^ help: there is an associated function with a similar name: `with_time`
[2022-10-31T14:18:27.529Z] 
Arctic26 commented 2 years ago

I am also getting this error, had to downgrade it to v0.14.20 since my project would not build with v0.14.21

mskrzypkows commented 2 years ago
hyper = { version = "=0.14.20", features = ["full"] }
sfackler commented 2 years ago

Looks like it needs a more complex blob of cfgs:

#[cfg(all(
        feature = "all",
        any(
            target_os = "android",
            target_os = "dragonfly",
            target_os = "freebsd",
            target_os = "fuchsia",
            target_os = "illumos",
            target_os = "linux",
            target_os = "netbsd",
            target_vendor = "apple",
            windows,
        )
    ))]
seanmonstar commented 2 years ago

PR to fix this, if any wants to confirm it works on their platform: https://github.com/hyperium/hyper/pull/3039

seanmonstar commented 2 years ago

Published v0.14.22 with the fix.

Arctic26 commented 2 years ago

I am still getting this error with v0.14.22 on Windows 10 Server


  --> C:\Users\Admin\.cargo\registry\src\github.com-1ecc6299db9ec823\hyper-0.14.22\src\server\tcp.rs:59:12
   |
59 |         ka.with_interval(interval)
   |            ^^^^^^^^^^^^^ method not found in 'TcpKeepalive'
ccbrown commented 2 years ago

Also still seeing the issue on macOS with 0.14.22:

   Compiling hyper v0.14.22
error[E0599]: no method named `with_interval` found for struct `TcpKeepalive` in the current scope
  --> /Users/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.22/src/server/tcp.rs:59:12
   |
59 |         ka.with_interval(interval)
   |            ^^^^^^^^^^^^^ method not found in `TcpKeepalive`

error[E0599]: no method named `with_retries` found for struct `TcpKeepalive` in the current scope
  --> /Users/chris/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.22/src/server/tcp.rs:89:12
   |
89 |         ka.with_retries(retries)
   |            ^^^^^^^^^^^^ help: there is an associated function with a similar name: `with_time`
seanmonstar commented 2 years ago

Can you check what version of socket2 is listed in your Cargo.lock? Maybe we need to force a newer one?

ccbrown commented 2 years ago

It was 0.4.1 for me. Adding this to my Cargo.toml does seem to resolve the issue:

socket2 = { version = "0.4.7", features = ["all"] }
seanmonstar commented 2 years ago

Ok, so for most people that run into this, I imagine this should fix you: cargo update -p socket2.

ccbrown commented 2 years ago

It doesn't. The version isn't the problem. Hyper is trying to use APIs that are only available when the "all" feature of socket2 is enabled.

This also fixes the issue:

socket2 = { version = "=0.4.1", features = ["all"] }

However, just updating to the latest socket2 does not help:

socket2 = "=0.4.7"

It appears to me that Hyper should have a features = ["all"] added to its socket2 dependency.

seanmonstar commented 2 years ago

Ah, interesting. I saw Tokio's Cargo.toml already sets that feature. (Doesn't mean hyper shouldn't). I suspect maybe just newer versions of Tokio have it set.

xoac commented 2 years ago

I got the same error and I didn't depend directly on hyper. I got error when I was running cargo clippy --tests --workspace

cargo clippy --tests --workspace
    Checking hyper v0.14.22
error[E0599]: no method named `with_interval` found for struct `TcpKeepalive` in the current scope
  --> /home/sr/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.22/src/server/tcp.rs:59:12
   |
59 |         ka.with_interval(interval)
   |            ^^^^^^^^^^^^^ method not found in `TcpKeepalive`

error[E0599]: no method named `with_retries` found for struct `TcpKeepalive` in the current scope
  --> /home/sr/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.22/src/server/tcp.rs:89:12
   |
89 |         ka.with_retries(retries)
   |            ^^^^^^^^^^^^ help: there is a method with a similar name: `with_time`

For more information about this error, try `rustc --explain E0599`.
error: could not compile `hyper` due to 2 previous errors

adding to Cargo.toml get rid of the error

socket2 = { version = "0.4", features = ["all"] }
davepacheco commented 2 years ago

v0.14.22 fails for us (dropshot) with a similar error. Is the problem what @ccbrown said, that hyper is missing a dependency on a socket2 feature?

seanmonstar commented 2 years ago

It looks like starting with Tokio v1.17, the features = ["all"] was added to its socket2 dependency. Are folks experiencing this issue even with Tokio newer than that?

I'll make sure the next 0.14.x release includes it explicitly.

xoac commented 2 years ago

@seanmonstar true I am using tokio with "~1.14.1" that is forced by dependency that I use.