Pure-Rust asynchronous SSH library, both client and server

#84 Doesn't compile on Windows

Opened by ministatsdev on December 2, 2023
ministatsdev on December 2, 2023

I’m trying to figure out why pijul doesn’t compile on Windows.

To that end, I tried to compile thrussh with openssl.

cargo check --workspace --features openssl --all-targets

This fails, with

warning: unused import: `self::kex::*`
  --> thrussh\src\server\mod.rs:33:9
   |
33 | pub use self::kex::*;
   |         ^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: variable does not need to be mutable
  --> thrussh\src\server\encrypted.rs:41:13
   |
41 |         let mut enc = self.common.encrypted.as_mut().unwrap();
   |             ----^^^
   |             |
   |             help: remove this `mut`
   |
   = note: `#[warn(unused_mut)]` on by default

warning: variable does not need to be mutable
   --> thrussh\src\server\encrypted.rs:122:13
    |
122 |         let mut enc = self.common.encrypted.as_mut().unwrap();
    |             ----^^^
    |             |
    |             help: remove this `mut`

    Checking thrussh-keys v0.22.1 (C:\Users\minin\Downloads\thrussh\thrussh-keys)
warning: `thrussh` (lib) generated 3 warnings (run `cargo fix --lib -p thrussh` to apply 3 suggestions)
warning: field `client_pubkey` is never read
   --> thrussh\src\lib.rs:713:9
    |
712 |     struct Server {
    |            ------ field in this struct
713 |         client_pubkey: Arc<thrussh_keys::key::PublicKey>,
    |         ^^^^^^^^^^^^^
    |
    = note: `Server` has a derived impl for the trait `Clone`, but this is intentionally ignored during dead code analysis
    = note: `#[warn(dead_code)]` on by default

warning: `thrussh` (lib test) generated 4 warnings (3 duplicates)
error[E0433]: failed to resolve: could not find `UnixStream` in `net`
   --> thrussh-keys\src\lib.rs:843:38
    |
843 |             let stream = tokio::net::UnixStream::connect(&agent_path).await?;
    |                                      ^^^^^^^^^^ could not find `UnixStream` in `net`

error[E0433]: failed to resolve: could not find `UnixListener` in `net`
   --> thrussh-keys\src\lib.rs:922:44
    |
922 |             let mut listener = tokio::net::UnixListener::bind(&agent_path_).unwrap();
    |                                            ^^^^^^^^^^^^
    |                                            |
    |                                            could not find `UnixListener` in `net`
    |                                            help: a struct with a similar name exists: `TcpListener`

error[E0433]: failed to resolve: could not find `UnixStream` in `net`
   --> thrussh-keys\src\lib.rs:935:38
    |
935 |             let stream = tokio::net::UnixStream::connect(&agent_path).await?;
    |                                      ^^^^^^^^^^ could not find `UnixStream` in `net`

error[E0412]: cannot find type `UnixListener` in module `tokio::net`
   --> thrussh-keys\src\lib.rs:959:39
    |
959 |         listener: &'a mut tokio::net::UnixListener,
    |                                       ^^^^^^^^^^^^ help: a struct with a similar name exists: `TcpListener`
    |
   ::: C:\Users\minin\scoop\persist\rustup\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tokio-1.34.0\src\net\tcp\listener.rs:54:5
    |
54  |     pub struct TcpListener {
    |     ---------------------- similarly named struct `TcpListener` defined here
    |
note: found an item that was configured out
   --> C:\Users\minin\scoop\persist\rustup\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tokio-1.34.0\src\net\mod.rs:50:29
    |
50  |     pub use unix::listener::UnixListener;
    |                             ^^^^^^^^^^^^

error[E0412]: cannot find type `UnixStream` in module `tokio::net`
   --> thrussh-keys\src\lib.rs:962:40
    |
962 |         type Item = Result<tokio::net::UnixStream, std::io::Error>;
    |                                        ^^^^^^^^^^ not found in `tokio::net`
    |
note: found an item that was configured out
   --> C:\Users\minin\scoop\persist\rustup\.cargo\registry\src\index.crates.io-6f17d22bba15001f\tokio-1.34.0\src\net\mod.rs:51:27
    |
51  |     pub use unix::stream::UnixStream;
    |                           ^^^^^^^^^^

Some errors have detailed explanations: E0412, E0433.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `thrussh-keys` (lib test) due to 5 previous errors
ministatsdev on December 2, 2023

These are all tests. A way to move forward is to put them behind a #[cfg(unix)].

korrat on January 13, 2024

Another problem is that the use-pkg-config feature of libsodium-sys is not compatible with MSVC, causing a panic in the build script (see https://github.com/sodiumoxide/sodiumoxide/blob/179e13c5bc3941e46f87f6748bfb3f9ed95936ba/libsodium-sys/build.rs#L90).