aboutsummaryrefslogtreecommitdiff
path: root/editors/code
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-02-20 17:35:37 +0000
committerGitHub <[email protected]>2021-02-20 17:35:37 +0000
commit0b4ec3c4e8d943dfe81fe22fdee636a714a9f87c (patch)
tree19299c4527109ca4b34edb83047d7c2eb9205211 /editors/code
parent364d572de80036d11ae13b3d8ebea9d0d5662a57 (diff)
parent23a8fc528406417a25479c09b4131d61126b4413 (diff)
Merge #7729
7729: Try to detect musl distros in the Code extension r=andylizi a=lnicola Fixes https://github.com/rust-analyzer/rust-analyzer/pull/7658#issuecomment-782701138 Co-authored-by: LaurenČ›iu Nicola <[email protected]>
Diffstat (limited to 'editors/code')
-rw-r--r--editors/code/src/main.ts14
1 files changed, 12 insertions, 2 deletions
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index 620810d72..00393d6e8 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -12,7 +12,7 @@ import { PersistentState } from './persistent_state';
12import { fetchRelease, download } from './net'; 12import { fetchRelease, download } from './net';
13import { activateTaskProvider } from './tasks'; 13import { activateTaskProvider } from './tasks';
14import { setContextValue } from './util'; 14import { setContextValue } from './util';
15import { exec } from 'child_process'; 15import { exec, spawnSync } from 'child_process';
16 16
17let ctx: Ctx | undefined; 17let ctx: Ctx | undefined;
18 18
@@ -297,7 +297,7 @@ async function getServer(config: Config, state: PersistentState): Promise<string
297 "arm64 linux": "aarch64-unknown-linux-gnu", 297 "arm64 linux": "aarch64-unknown-linux-gnu",
298 "arm64 darwin": "aarch64-apple-darwin", 298 "arm64 darwin": "aarch64-apple-darwin",
299 }; 299 };
300 const platform = platforms[`${process.arch} ${process.platform}`]; 300 let platform = platforms[`${process.arch} ${process.platform}`];
301 if (platform === undefined) { 301 if (platform === undefined) {
302 await vscode.window.showErrorMessage( 302 await vscode.window.showErrorMessage(
303 "Unfortunately we don't ship binaries for your platform yet. " + 303 "Unfortunately we don't ship binaries for your platform yet. " +
@@ -309,6 +309,9 @@ async function getServer(config: Config, state: PersistentState): Promise<string
309 ); 309 );
310 return undefined; 310 return undefined;
311 } 311 }
312 if (platform === "x86_64-unknown-linux-gnu" && isMusl()) {
313 platform = "x86_64-unknown-linux-musl";
314 }
312 const ext = platform.indexOf("-windows-") !== -1 ? ".exe" : ""; 315 const ext = platform.indexOf("-windows-") !== -1 ? ".exe" : "";
313 const dest = path.join(config.globalStoragePath, `rust-analyzer-${platform}${ext}`); 316 const dest = path.join(config.globalStoragePath, `rust-analyzer-${platform}${ext}`);
314 const exists = await fs.stat(dest).then(() => true, () => false); 317 const exists = await fs.stat(dest).then(() => true, () => false);
@@ -365,6 +368,13 @@ async function isNixOs(): Promise<boolean> {
365 } 368 }
366} 369}
367 370
371function isMusl(): boolean {
372 // We can detect Alpine by checking `/etc/os-release` but not Void Linux musl.
373 // Instead, we run `ldd` since it advertises the libc which it belongs to.
374 const res = spawnSync("ldd", ["--version"]);
375 return res.stderr != null && res.stderr.indexOf("musl libc") >= 0;
376}
377
368async function downloadWithRetryDialog<T>(state: PersistentState, downloadFunc: () => Promise<T>): Promise<T> { 378async function downloadWithRetryDialog<T>(state: PersistentState, downloadFunc: () => Promise<T>): Promise<T> {
369 while (true) { 379 while (true) {
370 try { 380 try {