Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
remote: Wrap `uname` invocation in `sh` for `nu` shell (#40084)
Lukas Wirth025938b4a552
diff --git a/crates/remote/src/transport/ssh.rs b/crates/remote/src/transport/ssh.rsindex a37d613056f..ae2987ec34c 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 {@@ -372,12 +373,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 {@@ -788,8 +789,13 @@ impl SshSocket {arguments}- async fn platform(&self) -> Result<RemotePlatform> {- let uname = self.run_command("uname", &["-sm"]).await?;+ async fn platform(&self, shell: ShellKind) -> Result<RemotePlatform> {+ 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.rsindex 6945b682b91..6a8ed48bc98 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<bool> {+ async fn detect_can_exec(&self, shell: ShellKind) -> Result<bool> {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<RemotePlatform> {- let arch_str = self.run_wsl_command("uname", &["-m"]).await?;+ async fn detect_platform(&self, shell: ShellKind) -> Result<RemotePlatform> {+ 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<String> {