jayjun / rambo

Run your command. Send input. Get output.
MIT License
199 stars 21 forks source link

Update socket2 Rust dependency to fix Windows build #25

Open talklittle opened 2 months ago

talklittle commented 2 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 1 month ago

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