From 8bd8ab4639f0edb5292940b43c70e30aeae83228 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 20 Aug 2026 15:07:32 +0000 Subject: [PATCH] Fix Windows russh Pageant connect and check it in CI. russh 0.54's AgentClient::connect_pageant returns Self, not Result, so with_context on that call failed the Release Windows build. Also add a windows-latest cargo check so #[cfg(windows)] SSH agent code is typed instead of only failing on Release. Co-authored-by: Pavitra Golchha --- .github/workflows/ci.yml | 19 +++++++++++++++++++ crates/based-ssh/src/tunnel.rs | 19 ++++++++++++------- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f64ef02..b36d3bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,3 +60,22 @@ jobs: - name: Build desktop run: cargo build -p desktop + + # Linux CI never type-checks `#[cfg(windows)]`. The release matrix does, so + # SSH-agent Windows APIs have to be checked here or they only fail on Release. + windows: + name: rust (windows check) + runs-on: windows-latest + steps: + - uses: actions/checkout@v6 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Cargo cache + uses: Swatinem/rust-cache@v2 + with: + workspaces: . -> target + + - name: Check desktop + run: cargo check -p desktop diff --git a/crates/based-ssh/src/tunnel.rs b/crates/based-ssh/src/tunnel.rs index f12c3f4..85f6225 100644 --- a/crates/based-ssh/src/tunnel.rs +++ b/crates/based-ssh/src/tunnel.rs @@ -189,16 +189,21 @@ async fn authenticate_with_agent( { // `connect_env` is Unix-only (SSH_AUTH_SOCK). Prefer OpenSSH's agent // named pipe, then Pageant. + // + // russh 0.54: `connect_named_pipe` returns Result, but `connect_pageant` + // returns `AgentClient` (not Result) — do not call `with_context` on it. match AgentClient::connect_named_pipe(r"\\.\pipe\openssh-ssh-agent").await { Ok(mut agent) => try_agent_identities(session, user, &mut agent).await, Err(openssh_err) => { - let mut agent = AgentClient::connect_pageant().await.with_context(|| { - format!( - "SSH tunnel: could not connect to OpenSSH agent \ - (\\\\.\\pipe\\openssh-ssh-agent: {openssh_err}) or Pageant" - ) - })?; - try_agent_identities(session, user, &mut agent).await + let mut agent = AgentClient::connect_pageant().await; + try_agent_identities(session, user, &mut agent) + .await + .with_context(|| { + format!( + "SSH tunnel: OpenSSH agent unavailable ({openssh_err}); \ + Pageant authentication failed" + ) + }) } } }