From 8813abed0042bf61954c92c668b8a06449e52a26 Mon Sep 17 00:00:00 2001 From: Xin Zhao Date: Mon, 5 Jan 2026 23:30:49 +0800 Subject: [PATCH] Enable terminal activation for uv-managed environments (#45949) Currently, the Python toolchain can identify `uv` and `uv-workspace` environments (showing the correct labels in the UI), but it fails to activate them when opening a new terminal. This is because the activation script resolution and command generation logic were missing for these environment kinds. This PR adds `uv` and `uv-workspace` to the standard virtual environment activation flow. Since `uv` creates environments with a standard `venv` structure, we can reuse the existing `resolve_venv_activation_scripts` logic to find and execute the appropriate `activate` scripts for different shells. Release Notes: - Fixed terminal activation for `uv` and `uv-workspace` Python environments. --- 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 23a067a6230dbacfe452d821104b7d8a2bdfa12a..bb257210be34815e7c533ce3db067a1eeec9b4c6 100644 --- a/crates/languages/src/python.rs +++ b/crates/languages/src/python.rs @@ -1358,7 +1358,12 @@ impl ToolchainLister for PythonToolchainProvider { activation_script.push(format!("{manager} activate base")); } } - Some(PythonEnvironmentKind::Venv | PythonEnvironmentKind::VirtualEnv) => { + Some( + PythonEnvironmentKind::Venv + | PythonEnvironmentKind::VirtualEnv + | PythonEnvironmentKind::Uv + | PythonEnvironmentKind::UvWorkspace, + ) => { if let Some(activation_scripts) = &toolchain.activation_scripts { if let Some(activate_script_path) = activation_scripts.get(&shell) { let activate_keyword = shell.activate_keyword(); @@ -1415,9 +1420,12 @@ async fn venv_to_toolchain(venv: PythonEnvironment, fs: &dyn Fs) -> Option { - resolve_venv_activation_scripts(&venv, fs, &mut activation_scripts).await - } + Some( + PythonEnvironmentKind::Venv + | PythonEnvironmentKind::VirtualEnv + | PythonEnvironmentKind::Uv + | PythonEnvironmentKind::UvWorkspace, + ) => resolve_venv_activation_scripts(&venv, fs, &mut activation_scripts).await, _ => {} } let data = PythonToolchainData {