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 <elliott.codes@gmail.com>
This commit is contained in:
parent
e6fe12d0e1
commit
53cfb578e8
1 changed files with 9 additions and 3 deletions
|
@ -770,6 +770,12 @@ impl PyLspAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
const BINARY_DIR: &str = if cfg!(target_os = "windows") {
|
||||
"Scripts"
|
||||
} else {
|
||||
"bin"
|
||||
};
|
||||
|
||||
#[async_trait(?Send)]
|
||||
impl LspAdapter for PyLspAdapter {
|
||||
fn name(&self) -> LanguageServerName {
|
||||
|
@ -811,7 +817,7 @@ impl LspAdapter for PyLspAdapter {
|
|||
delegate: &dyn LspAdapterDelegate,
|
||||
) -> Result<LanguageServerBinary> {
|
||||
let venv = self.base_venv(delegate).await.map_err(|e| anyhow!(e))?;
|
||||
let pip_path = venv.join("bin").join("pip3");
|
||||
let pip_path = venv.join(BINARY_DIR).join("pip3");
|
||||
ensure!(
|
||||
util::command::new_smol_command(pip_path.as_path())
|
||||
.arg("install")
|
||||
|
@ -842,7 +848,7 @@ impl LspAdapter for PyLspAdapter {
|
|||
.success(),
|
||||
"pylsp-mypy installation failed"
|
||||
);
|
||||
let pylsp = venv.join("bin").join("pylsp");
|
||||
let pylsp = venv.join(BINARY_DIR).join("pylsp");
|
||||
Ok(LanguageServerBinary {
|
||||
path: pylsp,
|
||||
env: None,
|
||||
|
@ -856,7 +862,7 @@ impl LspAdapter for PyLspAdapter {
|
|||
delegate: &dyn LspAdapterDelegate,
|
||||
) -> Option<LanguageServerBinary> {
|
||||
let venv = self.base_venv(delegate).await.ok()?;
|
||||
let pylsp = venv.join("bin").join("pylsp");
|
||||
let pylsp = venv.join(BINARY_DIR).join("pylsp");
|
||||
Some(LanguageServerBinary {
|
||||
path: pylsp,
|
||||
env: None,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue