From f2b7d8a9c9d67eefdfc0e0fcea798fe5b318f1b4 Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Thu, 20 Feb 2025 16:43:04 +0100 Subject: [PATCH] python: Properly check for Pyright language server in local environment (#24873) Closes #24565 As pointed out in https://github.com/zed-industries/zed/issues/24565#issuecomment-2657822723 , the name for the Pyright language server is `pyright-langserver`, not `pyright`. The latter is a CLI-tool as described in https://microsoft.github.io/pyright/#/command-line which only provides static type checking. It has neither LSP-capabilities nor a `--stdio` argument. Thus, the error as shown in the linked issue appears. I disagree with the fix as described in https://github.com/zed-industries/zed/issues/24565#issuecomment-2657904208 , as it could only cause this error to reappear in rare scenarios where Pyright, but not the Pyright language server is installed in a user's environment. Just checking for `pyright-langserver` to be present in the environment seems more straightforward here. Release Notes: - Python: Fixed Pyright failing to start when installed locally Co-authored-by: Beniamin Zagan <47153906+beniaminzagan@users.noreply.github.com> --- crates/languages/src/python.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/languages/src/python.rs b/crates/languages/src/python.rs index 7c72a2be9ac4393a9420756487e12ff98db8c085..c28a528418f8389d66f2aa14d6adc1556ec7f85f 100644 --- a/crates/languages/src/python.rs +++ b/crates/languages/src/python.rs @@ -83,7 +83,7 @@ impl LspAdapter for PythonLspAdapter { _: Arc, _: &AsyncApp, ) -> Option { - if let Some(pyright_bin) = delegate.which(Self::SERVER_NAME.as_ref()).await { + if let Some(pyright_bin) = delegate.which("pyright-langserver".as_ref()).await { let env = delegate.shell_env().await; Some(LanguageServerBinary { path: pyright_bin,