From 18a0e2d6b147e14fe6a9f2da7b03139e56bedcd5 Mon Sep 17 00:00:00 2001 From: gghhffyy368 Date: Sun, 1 Mar 2026 10:42:05 +0800 Subject: [PATCH 1/2] Fix PowerShell activation command quotes problem --- libmamba/src/core/activation.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libmamba/src/core/activation.cpp b/libmamba/src/core/activation.cpp index da261b0926..0a507f77d3 100644 --- a/libmamba/src/core/activation.cpp +++ b/libmamba/src/core/activation.cpp @@ -709,7 +709,14 @@ namespace mamba auto has_prefix = util::get_env("CONDA_PREFIX"); if (m_context.auto_activate_base && !has_prefix.has_value()) { - builder << get_self_exe_path().stem() << " activate base\n"; + if (is_powershell(this)) + { + builder << "& " << get_self_exe_path().stem() << " activate base\n"; + } + else + { + builder << get_self_exe_path().stem() << " activate base\n"; + } } builder << hook_postamble() << "\n"; return builder.str(); From 427a307c086d3733a69961a5d785e1cc31625778 Mon Sep 17 00:00:00 2001 From: gghhffyy368 Date: Sun, 1 Mar 2026 15:22:25 +0800 Subject: [PATCH 2/2] formatting codes --- libmamba/src/core/activation.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libmamba/src/core/activation.cpp b/libmamba/src/core/activation.cpp index 0a507f77d3..afc6b4abb0 100644 --- a/libmamba/src/core/activation.cpp +++ b/libmamba/src/core/activation.cpp @@ -709,14 +709,15 @@ namespace mamba auto has_prefix = util::get_env("CONDA_PREFIX"); if (m_context.auto_activate_base && !has_prefix.has_value()) { - if (is_powershell(this)) - { - builder << "& " << get_self_exe_path().stem() << " activate base\n"; - } - else - { - builder << get_self_exe_path().stem() << " activate base\n"; - } + // use invocation operator to run commands represented by strings + if (is_powershell(this)) + { + builder << "& " << get_self_exe_path().stem() << " activate base\n"; + } + else + { + builder << get_self_exe_path().stem() << " activate base\n"; + } } builder << hook_postamble() << "\n"; return builder.str();