diff --git a/Cargo.lock b/Cargo.lock index 0c4ea4752661026041b568a9149c55ee9ea0735c..ff5d7540d97f46e1d45a4b1e8587c05d41e2e507 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9986,6 +9986,7 @@ dependencies = [ "tempfile", "thiserror", "util", + "which 6.0.3", ] [[package]] diff --git a/crates/remote/Cargo.toml b/crates/remote/Cargo.toml index 8a199c56f66aef01229b04fb6d531b89422b471e..69d1d97c599a83fc8759893a58d98c2236688402 100644 --- a/crates/remote/Cargo.toml +++ b/crates/remote/Cargo.toml @@ -38,6 +38,7 @@ tempfile.workspace = true thiserror.workspace = true util.workspace = true release_channel.workspace = true +which.workspace = true [dev-dependencies] gpui = { workspace = true, features = ["test-support"] } diff --git a/crates/remote/src/ssh_session.rs b/crates/remote/src/ssh_session.rs index c607f0a0ec32167b929a84e750d2ae6aecc63e2e..20795be20148acbdf907ba416902b65b4b367b04 100644 --- a/crates/remote/src/ssh_session.rs +++ b/crates/remote/src/ssh_session.rs @@ -1428,9 +1428,21 @@ impl SshRemoteConnection { } }); + anyhow::ensure!( + which::which("nc").is_ok(), + "Cannot find nc, which is required to connect over ssh." + ); + // Create an askpass script that communicates back to this process. let askpass_script = format!( - "{shebang}\n{print_args} | nc -U {askpass_socket} 2> /dev/null \n", + "{shebang}\n{print_args} | {nc} -U {askpass_socket} 2> /dev/null \n", + // on macOS `brew install netcat` provides the GNU netcat implementation + // which does not support -U. + nc = if cfg!(target_os = "macos") { + "/usr/bin/nc" + } else { + "nc" + }, askpass_socket = askpass_socket.display(), print_args = "printf '%s\\0' \"$@\"", shebang = "#!/bin/sh",