terminal: Allow configuring conda manager (#40577)
Closes #40576 This PR makes Conda activation configurable and transparent by adding a `terminal.detect_venv.on.conda_manager` setting (`"auto" | "conda" | "mamba" | "micromamba"`, default `"auto"`), updating Python environment activation to honor this preference (or the detected manager executable) and fall back to `conda` when necessary. The preference is passed via `ZED_CONDA_MANAGER` from the terminal settings, and the activation command is built accordingly (with proper quoting for paths). Changes span `zed/crates/terminal/src/terminal_settings.rs` (new `CondaManager` and setting), `zed/crates/project/src/terminals.rs` (inject env var), `zed/crates/languages/src/python.rs` (activation logic), and `zed/assets/settings/default.json` (document the setting). Default behavior remains unchanged for most users while enabling explicit selection of `mamba` or `micromamba`. Release Notes: - Added: terminal.detect_venv.on.conda_manager setting to choose the Conda manager (auto, conda, mamba, micromamba). Default: auto. - Changed: Python Conda environment activation now respects the configured manager, otherwise uses the detected environment manager executable, and falls back to conda. - Reliability: Activation commands quote manager paths to handle spaces across platforms. - Compatibility: No breaking changes; non-Conda environments are unaffected; remote terminals are supported. --------- Co-authored-by: Lukas Wirth <me@lukaswirth.dev> Co-authored-by: Lukas Wirth <lukas@zed.dev>
This commit is contained in:
co-authored by
Lukas Wirth
Lukas Wirth
parent
082b80ec89
commit
9d52b6c538
@@ -10185,7 +10185,7 @@ fn python_lang(fs: Arc<FakeFs>) -> Arc<Language> {
|
||||
manifest_name: ManifestName::from(SharedString::new_static("pyproject.toml")),
|
||||
}
|
||||
}
|
||||
fn activation_script(&self, _: &Toolchain, _: ShellKind) -> Vec<String> {
|
||||
fn activation_script(&self, _: &Toolchain, _: ShellKind, _: &gpui::App) -> Vec<String> {
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,8 +127,10 @@ impl Project {
|
||||
.language_for_name(&toolchain.language_name.0)
|
||||
.await
|
||||
.ok();
|
||||
let lister = language?.toolchain_lister();
|
||||
return Some(lister?.activation_script(&toolchain, shell_kind));
|
||||
let lister = language?.toolchain_lister()?;
|
||||
return cx
|
||||
.update(|cx| lister.activation_script(&toolchain, shell_kind, cx))
|
||||
.ok();
|
||||
}
|
||||
None
|
||||
})
|
||||
@@ -317,7 +319,8 @@ impl Project {
|
||||
.unwrap_or_else(get_default_system_shell),
|
||||
None => settings.shell.program(),
|
||||
};
|
||||
let shell_kind = ShellKind::new(&shell, self.path_style(cx).is_windows());
|
||||
|
||||
let is_windows = self.path_style(cx).is_windows();
|
||||
|
||||
// Prepare a task for resolving the environment
|
||||
let env_task =
|
||||
@@ -325,6 +328,7 @@ impl Project {
|
||||
|
||||
let lang_registry = self.languages.clone();
|
||||
cx.spawn(async move |project, cx| {
|
||||
let shell_kind = ShellKind::new(&shell, is_windows);
|
||||
let mut env = env_task.await.unwrap_or_default();
|
||||
env.extend(settings.env);
|
||||
|
||||
@@ -337,13 +341,16 @@ impl Project {
|
||||
.language_for_name(&toolchain.language_name.0)
|
||||
.await
|
||||
.ok();
|
||||
let lister = language?.toolchain_lister();
|
||||
return Some(lister?.activation_script(&toolchain, shell_kind));
|
||||
let lister = language?.toolchain_lister()?;
|
||||
return cx
|
||||
.update(|cx| lister.activation_script(&toolchain, shell_kind, cx))
|
||||
.ok();
|
||||
}
|
||||
None
|
||||
})
|
||||
.await
|
||||
.unwrap_or_default();
|
||||
|
||||
let builder = project
|
||||
.update(cx, move |_, cx| {
|
||||
let (shell, env) = {
|
||||
|
||||
Reference in New Issue
Block a user