Skip to content
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

zls binary is deleted while installing it for zig 0.12.1 #210

Closed
akhildevelops opened this issue Jun 10, 2024 · 1 comment
Closed

zls binary is deleted while installing it for zig 0.12.1 #210

akhildevelops opened this issue Jun 10, 2024 · 1 comment
Labels

Comments

@akhildevelops
Copy link

Hi,

I observed that zls 0.12.1 isn't present for zig 0.12.1

When trying to install zls for zig 0.12.1 vs code extension deletes the exisiting 0.12.0 zls binary and shows the error that there's no corresponding binary.

Until error is fine but why the exisiting zls binary is deleted ?

@Vexu
Copy link
Member

Vexu commented Jun 10, 2024

Until error is fine but why the exisiting zls binary is deleted ?

Small oversight, the old version is deleted before the new one has been downloaded:

diff --git a/src/zls.ts b/src/zls.ts
index 57f8d65..f560247 100644
--- a/src/zls.ts
+++ b/src/zls.ts
@@ -293,15 +293,6 @@ async function installVersion(context: vscode.ExtensionContext, version: semver.
             location: vscode.ProgressLocation.Notification,
         },
         async (progress) => {
-            const installDir = vscode.Uri.joinPath(context.globalStorageUri, "zls_install");
-            if (fs.existsSync(installDir.fsPath)) {
-                fs.rmSync(installDir.fsPath, { recursive: true, force: true });
-            }
-            mkdirp.sync(installDir.fsPath);
-
-            const binName = `zls${isWindows ? ".exe" : ""}`;
-            const zlsBinPath = vscode.Uri.joinPath(installDir, binName).fsPath;
-
             progress.report({ message: "downloading executable..." });
             let exe: Buffer;
             try {
@@ -333,6 +324,15 @@ async function installVersion(context: vscode.ExtensionContext, version: semver.
                 }
                 throw err;
             }
+            const installDir = vscode.Uri.joinPath(context.globalStorageUri, "zls_install");
+            if (fs.existsSync(installDir.fsPath)) {
+                fs.rmSync(installDir.fsPath, { recursive: true, force: true });
+            }
+            mkdirp.sync(installDir.fsPath);
+
+            const binName = `zls${isWindows ? ".exe" : ""}`;
+            const zlsBinPath = vscode.Uri.joinPath(installDir, binName).fsPath;
+
             fs.writeFileSync(zlsBinPath, exe, "binary");
             fs.chmodSync(zlsBinPath, 0o755);
 

@Vexu Vexu added the bug label Jun 10, 2024
@Vexu Vexu closed this as completed in 93ce513 Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants