From: Laurențiu Nicola Date: Sat, 20 Feb 2021 16:39:26 +0000 (+0200) Subject: Try to detect musl distros in the Code extension X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=23a8fc528406417a25479c09b4131d61126b4413;p=rust.git Try to detect musl distros in the Code extension --- 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 true, () => false); @@ -365,6 +368,13 @@ async function isNixOs(): Promise { } } +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(state: PersistentState, downloadFunc: () => Promise): Promise { while (true) { try {