diff options
| author | Laurențiu Nicola <lnicola@dend.ro> | 2021-02-20 18:39:26 +0200 |
|---|---|---|
| committer | Laurențiu Nicola <lnicola@dend.ro> | 2021-02-20 18:44:28 +0200 |
| commit | 23a8fc528406417a25479c09b4131d61126b4413 (patch) | |
| tree | c3658151be61adcf93c94c06516a6e0b8d36f207 /editors/code/src | |
| parent | de67469f59d5c16e9b4ca106a0265bb8b1585c83 (diff) | |
| download | rust-23a8fc528406417a25479c09b4131d61126b4413.tar.gz rust-23a8fc528406417a25479c09b4131d61126b4413.zip | |
Try to detect musl distros in the Code extension
Diffstat (limited to 'editors/code/src')
| -rw-r--r-- | editors/code/src/main.ts | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 620810d7229..00393d6e8f2 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -12,7 +12,7 @@ import { PersistentState } from './persistent_state'; import { fetchRelease, download } from './net'; import { activateTaskProvider } from './tasks'; import { setContextValue } from './util'; -import { exec } from 'child_process'; +import { exec, spawnSync } from 'child_process'; let ctx: Ctx | undefined; @@ -297,7 +297,7 @@ async function getServer(config: Config, state: PersistentState): Promise<string "arm64 linux": "aarch64-unknown-linux-gnu", "arm64 darwin": "aarch64-apple-darwin", }; - const platform = platforms[`${process.arch} ${process.platform}`]; + let platform = platforms[`${process.arch} ${process.platform}`]; if (platform === undefined) { await vscode.window.showErrorMessage( "Unfortunately we don't ship binaries for your platform yet. " + @@ -309,6 +309,9 @@ async function getServer(config: Config, state: PersistentState): Promise<string ); return undefined; } + if (platform === "x86_64-unknown-linux-gnu" && isMusl()) { + platform = "x86_64-unknown-linux-musl"; + } const ext = platform.indexOf("-windows-") !== -1 ? ".exe" : ""; const dest = path.join(config.globalStoragePath, `rust-analyzer-${platform}${ext}`); const exists = await fs.stat(dest).then(() => true, () => false); @@ -365,6 +368,13 @@ async function isNixOs(): Promise<boolean> { } } +function isMusl(): boolean { + // We can detect Alpine by checking `/etc/os-release` but not Void Linux musl. + // Instead, we run `ldd` since it advertises the libc which it belongs to. + const res = spawnSync("ldd", ["--version"]); + return res.stderr != null && res.stderr.indexOf("musl libc") >= 0; +} + async function downloadWithRetryDialog<T>(state: PersistentState, downloadFunc: () => Promise<T>): Promise<T> { while (true) { try { |
