const config = new Config(context);
const state = new PersistentState(context.globalState);
- const serverPath = await bootstrap(config, state);
+ const serverPath = await bootstrap(config, state).catch(err => {
+ let message = "bootstrap error. ";
+
+ if (err.code === "EBUSY" || err.code === "ETXTBSY") {
+ message += "Other vscode windows might be using rust-analyzer, ";
+ message += "you should close them and reload this window to retry. ";
+ }
+
+ message += 'Open "Help > Toggle Developer Tools > Console" to see the logs ';
+ message += '(enable verbose logs with "rust-analyzer.trace.extension")';
+
+ log.error("Bootstrap error", err);
+ throw new Error(message);
+ });
const workspaceFolder = vscode.workspace.workspaceFolders?.[0];
if (workspaceFolder === undefined) {
ctx.registerCommand('applySnippetWorkspaceEdit', commands.applySnippetWorkspaceEditCommand);
ctx.registerCommand('resolveCodeAction', commands.resolveCodeAction);
ctx.registerCommand('applyActionGroup', commands.applyActionGroup);
+ ctx.registerCommand('gotoLocation', commands.gotoLocation);
ctx.pushCleanup(activateTaskProvider(workspaceFolder));
assert(!!artifact, `Bad release: ${JSON.stringify(release)}`);
const dest = path.join(config.globalStoragePath, "rust-analyzer.vsix");
- await download(artifact.browser_download_url, dest, "Downloading rust-analyzer extension");
+ await download({
+ url: artifact.browser_download_url,
+ dest,
+ progressTitle: "Downloading rust-analyzer extension",
+ });
await vscode.commands.executeCommand("workbench.extensions.installExtension", vscode.Uri.file(dest));
await fs.unlink(dest);
const artifact = release.assets.find(artifact => artifact.name === binaryName);
assert(!!artifact, `Bad release: ${JSON.stringify(release)}`);
- await download(artifact.browser_download_url, dest, "Downloading rust-analyzer server", { mode: 0o755 });
+ // Unlinking the exe file before moving new one on its place should prevent ETXTBSY error.
+ await fs.unlink(dest).catch(err => {
+ if (err.code !== "ENOENT") throw err;
+ });
+
+ await download({
+ url: artifact.browser_download_url,
+ dest,
+ progressTitle: "Downloading rust-analyzer server",
+ mode: 0o755
+ });
// Patching executable if that's NixOS.
if (await fs.stat("/etc/nixos").then(_ => true).catch(_ => false)) {