Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not force musl on linux #503

Merged
merged 1 commit into from
Feb 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
import { spawnSync } from "node:child_process";
import isWSL from "is-wsl";
import { workspace } from "vscode";

/**
* Whether the current platform uses musl
*/
export const isMusl = (() => {
// If not on Linux, or on WSL we can't be using musl
if (process.platform !== "linux" || isWSL) {
return false;
}

try {
const output = spawnSync("ldd", ["--version"], { encoding: "utf8" });
return output.stdout.includes("musl");
} catch {
return false;
}
})();

/**
* Platform identifier
*
Expand All @@ -14,11 +32,7 @@ import { workspace } from "vscode";
export const platformIdentifier = (() => {
let flavor = "";

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

Expand All @@ -44,7 +58,10 @@ export const platformSpecificBinaryName = (() => {
* This constant contains the name of Biome CLI GitHub release asset for the
* current platform.
*
* @example "biome-linux-x64"
* On Linux, we always return the musl flavor, as it's the most compatible
* since its statically linked.
*
* @example "biome-linux-x64-musl"
* @example "biome-darwin-x64"
* @example "biome-win32-x64.exe"
*/
Expand Down
11 changes: 10 additions & 1 deletion src/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
workspace,
} from "vscode";
import {
isMusl,
platformSpecificAssetName,
platformSpecificBinaryName,
} from "./constants";
Expand Down Expand Up @@ -49,8 +50,16 @@ const downloadBiomeVersion = async (
)
.json();

let assetName = platformSpecificAssetName;

// On Linux, we always want to download the musl flavor, because it's the most
// compatible since it's statically linked.
if (process.platform === "linux" && !isMusl) {
assetName = `${assetName}-musl`;
}

const asset = releases.assets.find((asset) => {
return asset.name === platformSpecificAssetName;
return asset.name === assetName;
});

if (!asset) {
Expand Down