diff --git a/crates/util/src/util.rs b/crates/util/src/util.rs index 9b099f04983909b55e0fc5c161fd911210e96f37..87b8a1615d86c74fa4b3b1cb7c89fc94939558a0 100644 --- a/crates/util/src/util.rs +++ b/crates/util/src/util.rs @@ -304,8 +304,19 @@ fn load_shell_from_passwd() -> Result<()> { /// Returns a shell escaped path for the current zed executable pub fn get_shell_safe_zed_path(shell_kind: shell::ShellKind) -> anyhow::Result { - let zed_path = + let mut zed_path = std::env::current_exe().context("Failed to determine current zed executable path.")?; + if cfg!(target_os = "linux") + && !zed_path.is_file() + && let Some(truncated) = zed_path + .clone() + .file_name() + .and_then(|s| s.to_str()) + .and_then(|n| n.strip_suffix(" (deleted)")) + { + // Might have been deleted during update; let's use the new binary if there is one. + zed_path.set_file_name(truncated); + } zed_path .try_shell_safe(shell_kind)