Skip to content

Commit a895331

Browse files
authored
fix: do not force musl on linux (#503)
1 parent 36feb9e commit a895331

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

src/constants.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
1+
import { spawnSync } from "node:child_process";
12
import isWSL from "is-wsl";
23
import { workspace } from "vscode";
34

5+
/**
6+
* Whether the current platform uses musl
7+
*/
8+
export const isMusl = (() => {
9+
// If not on Linux, or on WSL we can't be using musl
10+
if (process.platform !== "linux" || isWSL) {
11+
return false;
12+
}
13+
14+
try {
15+
const output = spawnSync("ldd", ["--version"], { encoding: "utf8" });
16+
return output.stdout.includes("musl");
17+
} catch {
18+
return false;
19+
}
20+
})();
21+
422
/**
523
* Platform identifier
624
*
@@ -14,11 +32,7 @@ import { workspace } from "vscode";
1432
export const platformIdentifier = (() => {
1533
let flavor = "";
1634

17-
// On Linux, we always use the `musl` flavor because it has the advantage of
18-
// having been built statically. This is meant to improve the compatibility
19-
// with various systems such as NixOS, which handle dynamically linked
20-
// binaries differently.
21-
if (process.platform === "linux" && !isWSL) {
35+
if (isMusl) {
2236
flavor = "-musl";
2337
}
2438

@@ -44,7 +58,10 @@ export const platformSpecificBinaryName = (() => {
4458
* This constant contains the name of Biome CLI GitHub release asset for the
4559
* current platform.
4660
*
47-
* @example "biome-linux-x64"
61+
* On Linux, we always return the musl flavor, as it's the most compatible
62+
* since its statically linked.
63+
*
64+
* @example "biome-linux-x64-musl"
4865
* @example "biome-darwin-x64"
4966
* @example "biome-win32-x64.exe"
5067
*/

src/downloader.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
workspace,
1010
} from "vscode";
1111
import {
12+
isMusl,
1213
platformSpecificAssetName,
1314
platformSpecificBinaryName,
1415
} from "./constants";
@@ -49,8 +50,16 @@ const downloadBiomeVersion = async (
4950
)
5051
.json();
5152

53+
let assetName = platformSpecificAssetName;
54+
55+
// On Linux, we always want to download the musl flavor, because it's the most
56+
// compatible since it's statically linked.
57+
if (process.platform === "linux" && !isMusl) {
58+
assetName = `${assetName}-musl`;
59+
}
60+
5261
const asset = releases.assets.find((asset) => {
53-
return asset.name === platformSpecificAssetName;
62+
return asset.name === assetName;
5463
});
5564

5665
if (!asset) {

0 commit comments

Comments
 (0)