windows: Detect when python3 is not usable and notify the user (#40070)

Fixes #39998

Debugpy and pylsp are installed in a Zed-global venv with pip. We need a
Python interpreter to create this venv when it doesn't exist and one of
these tools needs to be installed, and sometimes we attempt to use
`python3` from `$PATH`. This can cause issues on Windows, where out of
the box `python3` is a sort of shim that opens the Microsoft Store app.

This PR changes the debugpy installation path to create the Zed-global
venv using the Python interpreter from a venv in the project, and only
use python3 from `$PATH` if that fails. That matches how pylsp
installation already works. It also tightens up how we search for a
global Python installation by doing a basic sanity check (`python3 -c
'print(1 + 2)`) before accepting it, which should catch the Windows
shim.

Release Notes:

- windows: improved the behavior of Zed in situations where no global
Python installation exists.
This commit is contained in:
Cole Miller
2025-10-13 21:11:33 +00:00
committed by GitHub
parent f0d097c66a
commit 6a1648825c
4 changed files with 135 additions and 87 deletions
+2 -2
View File
@@ -268,12 +268,12 @@ impl DebugPanel {
async move |_, cx| {
if let Err(error) = task.await {
log::error!("{error}");
log::error!("{error:#}");
session
.update(cx, |session, cx| {
session
.console_output(cx)
.unbounded_send(format!("error: {}", error))
.unbounded_send(format!("error: {:#}", error))
.ok();
session.shutdown(cx)
})?