cloudflare / foundations

Cloudflare's Rust service foundations library.
https://blog.cloudflare.com/introducing-foundations-our-open-source-rust-service-foundation-library
BSD 3-Clause "New" or "Revised" License
1.3k stars 56 forks source link

Failing to compile 3.1.1 #5

Closed wathiede closed 9 months ago

wathiede commented 9 months ago

I'm seeing

error[E0599]: no method named `set_reuse_port` found for struct `Socket` in the current scope
   --> .../foundations/foundations/src/telemetry/server.rs:139:12
    |                                                                                                                       
139 |     socket.set_reuse_port(true)?;
    |            ^^^^^^^^^^^^^^ method not found in `Socket`

For more information about this error, try `rustc --explain E0599`.
error: could not compile `foundations` (lib) due to 1 previous error

It would appear this method isn't available unless socket2 is compiled with the all feature, see https://github.com/rust-lang/socket2/blob/master/src/sys/unix.rs#L2134-L2151

inikulin commented 9 months ago

Hi, thank you for the contribution.

This makes sense, but I'm confused by the fact that we don't see failures in CI and using the library on our side. Could you share the feature combination that you're using and Rust version?

Noah-Kennedy commented 9 months ago

What operating system are you on?

wathiede commented 9 months ago

I think I see the problem, and it's probably not worth accepting this pull request.

A minimal fresh project trying to use foundations on my machine works, but when I first tried to use foundations by adding it to an existing program I got the error listed above. By comparing cargo tree output from the working and non-working crates, I realized the Cargo.lock for the broken crate had hyper=0.14.16 which included socket2=0.4.3. If I cargo update that crate things build.

I might still push for this PR, or another that was more specific about the hyper versions (later versions include socket=0.5.5 like foundations do), but I see https://crates.io/crates/socket2/0.4.3 was yanked. So this is really an esoteric issue caused by my stale lockfile.

Sorry for the noise.

Noah-Kennedy commented 9 months ago

If we are relying on features in direct dependencies that we are failing to specify, then that is a bug.

If you reopen the PR, either I or @inikulin will merge.

Noah-Kennedy commented 9 months ago

Merged #6.