Skip to content

Commit 6b8b1e6

Browse files
python: Fix ty binary path and required args (#38458)
Closes #38347 Release Notes: - Fixed path and args to ty lsp binary When attempting to use the new ty lsp integration in the preview, I noticed issues related to accessing the binary. After deleting the downloaded archive and adding the following changes that: - downloads the archive with the correct `AssetKind::TarGz` - uses the correct path to the extracted binary - adds the `server` argument to initialize the lsp (like ruff) After the above changes the LSP starts correctly ```bash 2025-09-18T16:17:03-05:00 INFO [lsp] starting language server process. binary path: "/Users/dereknguyen/Library/Application Support/Zed/languages/ty/ty-0.0.1-alpha.20/ty-aarch64-apple-darwin/ty", working directory: "/Users/dereknguyen/projects/test-project", args: ["server"] ``` <img width="206" height="98" alt="image" src="https://github.com/user-attachments/assets/8fcf423f-40a0-4cd9-a79e-e09666323fe2" /> --------- Co-authored-by: Cole Miller <[email protected]>
1 parent de412e4 commit 6b8b1e6

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

crates/languages/src/python.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub struct TyLspAdapter {
100100

101101
#[cfg(target_os = "macos")]
102102
impl TyLspAdapter {
103-
const GITHUB_ASSET_KIND: AssetKind = AssetKind::Gz;
103+
const GITHUB_ASSET_KIND: AssetKind = AssetKind::TarGz;
104104
const ARCH_SERVER_NAME: &str = "apple-darwin";
105105
}
106106

@@ -216,15 +216,20 @@ impl LspInstaller for TyLspAdapter {
216216
digest: expected_digest,
217217
} = latest_version;
218218
let destination_path = container_dir.join(format!("ty-{name}"));
219+
220+
async_fs::create_dir_all(&destination_path).await?;
221+
219222
let server_path = match Self::GITHUB_ASSET_KIND {
220-
AssetKind::TarGz | AssetKind::Gz => destination_path.clone(), // Tar and gzip extract in place.
221-
AssetKind::Zip => destination_path.clone().join("ty.exe"), // zip contains a .exe
223+
AssetKind::TarGz | AssetKind::Gz => destination_path
224+
.join(Self::build_asset_name()?.0)
225+
.join("ty"),
226+
AssetKind::Zip => destination_path.clone().join("ty.exe"),
222227
};
223228

224229
let binary = LanguageServerBinary {
225230
path: server_path.clone(),
226231
env: None,
227-
arguments: Default::default(),
232+
arguments: vec!["server".into()],
228233
};
229234

230235
let metadata_path = destination_path.with_extension("metadata");
@@ -283,7 +288,7 @@ impl LspInstaller for TyLspAdapter {
283288
Ok(LanguageServerBinary {
284289
path: server_path,
285290
env: None,
286-
arguments: Default::default(),
291+
arguments: vec!["server".into()],
287292
})
288293
}
289294

@@ -305,14 +310,16 @@ impl LspInstaller for TyLspAdapter {
305310

306311
let path = last.context("no cached binary")?;
307312
let path = match TyLspAdapter::GITHUB_ASSET_KIND {
308-
AssetKind::TarGz | AssetKind::Gz => path, // Tar and gzip extract in place.
309-
AssetKind::Zip => path.join("ty.exe"), // zip contains a .exe
313+
AssetKind::TarGz | AssetKind::Gz => {
314+
path.join(Self::build_asset_name()?.0).join("ty")
315+
}
316+
AssetKind::Zip => path.join("ty.exe"),
310317
};
311318

312319
anyhow::Ok(LanguageServerBinary {
313320
path,
314321
env: None,
315-
arguments: Default::default(),
322+
arguments: vec!["server".into()],
316323
})
317324
})
318325
.await

0 commit comments

Comments
 (0)