jayjun / rambo

Run your command. Send input. Get output.
MIT License
204 stars 23 forks source link

Update socket2 Rust dependency to fix Windows build #25

Open talklittle opened 5 months ago

talklittle commented 5 months ago

Fixes Windows compile by updating the socket2 Rust dependency to 0.3.19.

Fixes #21


Reproduce the error by running docker:

$ cd priv

# build the Windows Docker image
$ docker build -t rambo-windows -f Dockerfile.x86_64-pc-windows-gnu .

# attempt the Rambo build inside a Windows Docker container
$ docker run rambo-windows

Results in this Rust error:

   Compiling socket2 v0.3.11
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
   --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/socket2-0.3.11/src/sockaddr.rs:156:9
    |
156 |         mem::transmute::<SocketAddrV4, sockaddr_in>(v4);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: source type: `SocketAddrV4` (48 bits)
    = note: target type: `SOCKADDR_IN` (128 bits)

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

After adding a dependency on socket2 version 0.3.19 in Cargo.toml, and rebuilding the Docker image, the Rambo compilation succeeds.

Relevant socket2 issue: https://github.com/rust-lang/socket2/issues/119 fixed in v0.3.16

talklittle commented 4 months ago

Updated. Adding explicit dependency wasn't needed; instead use $ cargo update -p socket2 to update the Cargo.lock file.

dev10 commented 2 months ago

I can confirm this builds fine on Windows with the latest version of Rust(1.81.0) I haven't tested in docker though as I don't use it on Windows.