From 860aa7889c1fe3fa6ca63da8ba4f833f803a4238 Mon Sep 17 00:00:00 2001 From: Adam Ehlers Nyholm Thomsen Date: Mon, 4 May 2026 18:44:18 +0200 Subject: [PATCH] Fix micromamba powershell activation (#55643) Powershell does not support eval, furthermore pwsh is also a "powershell" shell for micromamba. Self-Review Checklist: - [X] I've reviewed my own diff for quality, security, and reliability - [X] Unsafe blocks (if any) have justifying comments - [X] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [ ] Tests cover the new/changed behavior - [X] Performance impact has been considered and is acceptable Release Notes: - Fixes micromamba powershell activation --- crates/languages/src/python.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/crates/languages/src/python.rs b/crates/languages/src/python.rs index 5cdff8654f..26e96789a0 100644 --- a/crates/languages/src/python.rs +++ b/crates/languages/src/python.rs @@ -1259,7 +1259,7 @@ fn micromamba_shell_name(kind: ShellKind) -> &'static str { ShellKind::Csh => "csh", ShellKind::Fish => "fish", ShellKind::Nushell => "nu", - ShellKind::PowerShell => "powershell", + ShellKind::PowerShell | ShellKind::Pwsh => "powershell", ShellKind::Cmd => "cmd.exe", // default / catch-all: _ => "posix", @@ -1470,9 +1470,17 @@ impl ToolchainLister for PythonToolchainProvider { // Activate micromamba shell in the child shell // [required for micromamba] if manager == "micromamba" { - let shell = micromamba_shell_name(shell); - activation_script - .push(format!(r#"eval "$({manager} shell hook --shell {shell})""#)); + match shell { + ShellKind::PowerShell | ShellKind::Pwsh => { + activation_script.push(format!(r#"(& {manager} shell hook --shell powershell) | Out-String | Invoke-Expression"#)); + } + _ => { + let shell_name = micromamba_shell_name(shell); + activation_script.push(format!( + r#"eval "$({manager} shell hook --shell {shell_name})""# + )); + } + } } if let Some(name) = &toolchain.environment.name {