From 23a8fc528406417a25479c09b4131d61126b4413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Sat, 20 Feb 2021 18:39:26 +0200 Subject: Try to detect musl distros in the Code extension --- editors/code/src/main.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'editors/code/src/main.ts') 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'; 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 { -- cgit v1.2.3