diff --git a/crates/remote/src/transport/ssh.rs b/crates/remote/src/transport/ssh.rs index d18b46b3d011c857023c0f091730ea10014c931a..27548d11bae4293ffcaa03707dc535b3eb13985f 100644 --- a/crates/remote/src/transport/ssh.rs +++ b/crates/remote/src/transport/ssh.rs @@ -29,6 +29,7 @@ use tempfile::TempDir; use util::{ paths::{PathStyle, RemotePathBuf}, rel_path::RelPath, + shell::ShellKind, }; pub(crate) struct SshRemoteConnection { @@ -355,12 +356,12 @@ impl SshRemoteConnection { .await?; drop(askpass); - let ssh_platform = socket.platform().await?; + let ssh_shell = socket.shell().await; + let ssh_platform = socket.platform(ShellKind::new(&ssh_shell, false)).await?; let ssh_path_style = match ssh_platform.os { "windows" => PathStyle::Windows, _ => PathStyle::Posix, }; - let ssh_shell = socket.shell().await; let ssh_default_system_shell = String::from("/bin/sh"); let mut this = Self { @@ -771,8 +772,13 @@ impl SshSocket { arguments } - async fn platform(&self) -> Result { - let uname = self.run_command("uname", &["-sm"]).await?; + async fn platform(&self, shell: ShellKind) -> Result { + let program = if shell == ShellKind::Nushell { + "^uname" + } else { + "uname" + }; + let uname = self.run_command(program, &["-sm"]).await?; let Some((os, arch)) = uname.split_once(" ") else { anyhow::bail!("unknown uname: {uname:?}") }; diff --git a/crates/remote/src/transport/wsl.rs b/crates/remote/src/transport/wsl.rs index 6745c4409a0acf39b86999335f7d0826fc978e09..0972d6b8b126a48fb0b32b4ea8cca7d4a504415b 100644 --- a/crates/remote/src/transport/wsl.rs +++ b/crates/remote/src/transport/wsl.rs @@ -21,6 +21,7 @@ use std::{ use util::{ paths::{PathStyle, RemotePathBuf}, rel_path::RelPath, + shell::ShellKind, }; #[derive(Debug, Clone, PartialEq, Eq, Hash)] @@ -76,9 +77,10 @@ impl WslRemoteConnection { can_exec: true, }; delegate.set_status(Some("Detecting WSL environment"), cx); - this.can_exec = this.detect_can_exec().await?; - this.platform = this.detect_platform().await?; this.shell = this.detect_shell().await?; + let shell = ShellKind::new(&this.shell, false); + this.can_exec = this.detect_can_exec(shell).await?; + this.platform = this.detect_platform(shell).await?; this.remote_binary_path = Some( this.ensure_server_binary(&delegate, release_channel, version, commit, cx) .await?, @@ -88,9 +90,13 @@ impl WslRemoteConnection { Ok(this) } - async fn detect_can_exec(&self) -> Result { + async fn detect_can_exec(&self, shell: ShellKind) -> Result { let options = &self.connection_options; - let program = "uname"; + let program = if shell == ShellKind::Nushell { + "^uname" + } else { + "uname" + }; let args = &["-m"]; let output = wsl_command_impl(options, program, args, true) .output() @@ -114,9 +120,14 @@ impl WslRemoteConnection { Ok(true) } } - - async fn detect_platform(&self) -> Result { - let arch_str = self.run_wsl_command("uname", &["-m"]).await?; + async fn detect_platform(&self, shell: ShellKind) -> Result { + let arch_str = if shell == ShellKind::Nushell { + // https://github.com/nushell/nushell/issues/12570 + self.run_wsl_command("sh", &["-c", "uname -m"]) + } else { + self.run_wsl_command("uname", &["-m"]) + } + .await?; let arch_str = arch_str.trim().to_string(); let arch = match arch_str.as_str() { "x86_64" => "x86_64", @@ -131,7 +142,7 @@ impl WslRemoteConnection { .run_wsl_command("sh", &["-c", "echo $SHELL"]) .await .ok() - .unwrap_or_else(|| "bash".to_string())) + .unwrap_or_else(|| "/bin/sh".to_string())) } async fn windows_path_to_wsl_path(&self, source: &Path) -> Result {