diff options
Diffstat (limited to 'editors/code/src/main.ts')
-rw-r--r-- | editors/code/src/main.ts | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 270fbcb64..670f2ebfd 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts | |||
@@ -42,7 +42,16 @@ export async function activate(context: vscode.ExtensionContext) { | |||
42 | 42 | ||
43 | const config = new Config(context); | 43 | const config = new Config(context); |
44 | const state = new PersistentState(context.globalState); | 44 | const state = new PersistentState(context.globalState); |
45 | const serverPath = await bootstrap(config, state); | 45 | const serverPath = await bootstrap(config, state).catch(err => { |
46 | let message = "Failed to bootstrap rust-analyzer."; | ||
47 | if (err.code === "EBUSY" || err.code === "ETXTBSY") { | ||
48 | message += " Other vscode windows might be using rust-analyzer, " + | ||
49 | "you should close them and reload this window to retry."; | ||
50 | } | ||
51 | message += " Open \"Help > Toggle Developer Tools > Console\" to see the logs"; | ||
52 | log.error("Bootstrap error", err); | ||
53 | throw new Error(message); | ||
54 | }); | ||
46 | 55 | ||
47 | const workspaceFolder = vscode.workspace.workspaceFolders?.[0]; | 56 | const workspaceFolder = vscode.workspace.workspaceFolders?.[0]; |
48 | if (workspaceFolder === undefined) { | 57 | if (workspaceFolder === undefined) { |
@@ -285,6 +294,11 @@ async function getServer(config: Config, state: PersistentState): Promise<string | |||
285 | const artifact = release.assets.find(artifact => artifact.name === binaryName); | 294 | const artifact = release.assets.find(artifact => artifact.name === binaryName); |
286 | assert(!!artifact, `Bad release: ${JSON.stringify(release)}`); | 295 | assert(!!artifact, `Bad release: ${JSON.stringify(release)}`); |
287 | 296 | ||
297 | // Unlinking the exe file before moving new one on its place should prevent ETXTBSY error. | ||
298 | await fs.unlink(dest).catch(err => { | ||
299 | if (err.code !== "ENOENT") throw err; | ||
300 | }); | ||
301 | |||
288 | await download(artifact.browser_download_url, dest, "Downloading rust-analyzer server", { mode: 0o755 }); | 302 | await download(artifact.browser_download_url, dest, "Downloading rust-analyzer server", { mode: 0o755 }); |
289 | 303 | ||
290 | // Patching executable if that's NixOS. | 304 | // Patching executable if that's NixOS. |