-
Notifications
You must be signed in to change notification settings - Fork 7k
fix(win32): Missing LSP can now unzip on windows #5594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -9,6 +9,7 @@ import fs from "fs/promises" | |||||||||||||||||||||
| import { Filesystem } from "../util/filesystem" | ||||||||||||||||||||||
| import { Instance } from "../project/instance" | ||||||||||||||||||||||
| import { Flag } from "../flag/flag" | ||||||||||||||||||||||
| import { Archive } from "../util/archive" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export namespace LSPServer { | ||||||||||||||||||||||
| const log = Log.create({ service: "lsp.server" }) | ||||||||||||||||||||||
|
|
@@ -176,7 +177,7 @@ export namespace LSPServer { | |||||||||||||||||||||
| const zipPath = path.join(Global.Path.bin, "vscode-eslint.zip") | ||||||||||||||||||||||
| await Bun.file(zipPath).write(response) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| await $`unzip -o -q ${zipPath}`.quiet().cwd(Global.Path.bin).nothrow() | ||||||||||||||||||||||
| await Archive.extractZip(zipPath, Global.Path.bin) | ||||||||||||||||||||||
| await fs.rm(zipPath, { force: true }) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const extractedPath = path.join(Global.Path.bin, "vscode-eslint-main") | ||||||||||||||||||||||
|
|
@@ -438,7 +439,7 @@ export namespace LSPServer { | |||||||||||||||||||||
| const zipPath = path.join(Global.Path.bin, "elixir-ls.zip") | ||||||||||||||||||||||
| await Bun.file(zipPath).write(response) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| await $`unzip -o -q ${zipPath}`.quiet().cwd(Global.Path.bin).nothrow() | ||||||||||||||||||||||
| await Archive.extractZip(zipPath, Global.Path.bin) | ||||||||||||||||||||||
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| await fs.rm(zipPath, { | ||||||||||||||||||||||
| force: true, | ||||||||||||||||||||||
|
|
@@ -541,7 +542,7 @@ export namespace LSPServer { | |||||||||||||||||||||
| await Bun.file(tempPath).write(downloadResponse) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if (ext === "zip") { | ||||||||||||||||||||||
| await $`unzip -o -q ${tempPath}`.quiet().cwd(Global.Path.bin).nothrow() | ||||||||||||||||||||||
| await Archive.extractZip(tempPath, Global.Path.bin) | ||||||||||||||||||||||
|
||||||||||||||||||||||
| } else { | ||||||||||||||||||||||
| await $`tar -xf ${tempPath}`.cwd(Global.Path.bin).nothrow() | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
@@ -840,7 +841,7 @@ export namespace LSPServer { | |||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if (zip) { | ||||||||||||||||||||||
| await $`unzip -o -q ${archive}`.quiet().cwd(Global.Path.bin).nothrow() | ||||||||||||||||||||||
| await Archive.extractZip(archive, Global.Path.bin) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+844
to
845
|
||||||||||||||||||||||
| await Archive.extractZip(archive, Global.Path.bin) | |
| } | |
| try { | |
| await Archive.extractZip(archive, Global.Path.bin) | |
| } catch (err) { | |
| log.error("Failed to extract clangd zip archive", { error: err }); | |
| await fs.rm(archive, { force: true }); | |
| return; | |
| } |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing error handling: The original code used .nothrow() which prevents exceptions from propagating. The new Archive.extractZip call can throw exceptions. If extraction fails, the subsequent cleanup and verification steps will not execute, potentially leaving the system in an inconsistent state.
| await Archive.extractZip(tempPath, Global.Path.bin) | |
| await fs.rm(tempPath, { force: true }) | |
| try { | |
| await Archive.extractZip(tempPath, Global.Path.bin) | |
| } catch (err) { | |
| log.error("Failed to extract terraform-ls zip", { error: err }) | |
| return | |
| } finally { | |
| await fs.rm(tempPath, { force: true }) | |
| } |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing error handling: The original code used .nothrow() which prevents exceptions from propagating. The new Archive.extractZip call can throw exceptions. If extraction fails, the subsequent cleanup and verification steps will not execute, potentially leaving the system in an inconsistent state.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { $ } from "bun" | ||
| import path from "path" | ||
|
|
||
| export namespace Archive { | ||
| export async function extractZip(zipPath: string, destDir: string) { | ||
| if (process.platform === "win32") { | ||
| const winZipPath = path.resolve(zipPath) | ||
| const winDestDir = path.resolve(destDir) | ||
| // $global:ProgressPreference suppresses PowerShell's blue progress bar popup | ||
| const cmd = `$global:ProgressPreference = 'SilentlyContinue'; Expand-Archive -Path '${winZipPath}' -DestinationPath '${winDestDir}' -Force` | ||
|
||
| await $`powershell -NoProfile -NonInteractive -Command ${cmd}`.quiet() | ||
|
||
| } else { | ||
| await $`unzip -o -q ${zipPath} -d ${destDir}`.quiet() | ||
|
||
| } | ||
|
Comment on lines
+5
to
+14
|
||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing error handling: The original code used
.nothrow()which prevents exceptions from propagating. The new Archive.extractZip call can throw exceptions. If extraction fails, the subsequent cleanup code (removing zip file, renaming directories) will not execute, potentially leaving the system in an inconsistent state.