aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorLaurenČ›iu Nicola <[email protected]>2021-02-20 16:39:26 +0000
committerLaurenČ›iu Nicola <[email protected]>2021-02-20 16:44:28 +0000
commit23a8fc528406417a25479c09b4131d61126b4413 (patch)
treec3658151be61adcf93c94c06516a6e0b8d36f207 /editors
parentde67469f59d5c16e9b4ca106a0265bb8b1585c83 (diff)
Try to detect musl distros in the Code extension
Diffstat (limited to 'editors')
-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 {