Skip to content

Commit 53cfb57

Browse files
python: Adjust binary path based on OS (#22587)
Closes #ISSUE - #21452 Describe the bug / provide steps to reproduce it Language server error: pylsp failed to spawn command. path: "C:\Users\AppData\Local\Zed\languages\pylsp\pylsp-venv\bin\pylsp", working directory: "D:\Coding\Python", args: [] -- stderr-- Environment - Windows 11 - python Release Notes: - Windows: Fixed the path building used to run `pip` commands in the venv generated on Windows 11. --------- Co-authored-by: Marshall Bowers <[email protected]>
1 parent e6fe12d commit 53cfb57

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

crates/languages/src/python.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,12 @@ impl PyLspAdapter {
770770
}
771771
}
772772

773+
const BINARY_DIR: &str = if cfg!(target_os = "windows") {
774+
"Scripts"
775+
} else {
776+
"bin"
777+
};
778+
773779
#[async_trait(?Send)]
774780
impl LspAdapter for PyLspAdapter {
775781
fn name(&self) -> LanguageServerName {
@@ -811,7 +817,7 @@ impl LspAdapter for PyLspAdapter {
811817
delegate: &dyn LspAdapterDelegate,
812818
) -> Result<LanguageServerBinary> {
813819
let venv = self.base_venv(delegate).await.map_err(|e| anyhow!(e))?;
814-
let pip_path = venv.join("bin").join("pip3");
820+
let pip_path = venv.join(BINARY_DIR).join("pip3");
815821
ensure!(
816822
util::command::new_smol_command(pip_path.as_path())
817823
.arg("install")
@@ -842,7 +848,7 @@ impl LspAdapter for PyLspAdapter {
842848
.success(),
843849
"pylsp-mypy installation failed"
844850
);
845-
let pylsp = venv.join("bin").join("pylsp");
851+
let pylsp = venv.join(BINARY_DIR).join("pylsp");
846852
Ok(LanguageServerBinary {
847853
path: pylsp,
848854
env: None,
@@ -856,7 +862,7 @@ impl LspAdapter for PyLspAdapter {
856862
delegate: &dyn LspAdapterDelegate,
857863
) -> Option<LanguageServerBinary> {
858864
let venv = self.base_venv(delegate).await.ok()?;
859-
let pylsp = venv.join("bin").join("pylsp");
865+
let pylsp = venv.join(BINARY_DIR).join("pylsp");
860866
Some(LanguageServerBinary {
861867
path: pylsp,
862868
env: None,

0 commit comments

Comments
 (0)