biomejs/biome-vscode

๐Ÿ› Wrong biome build used for musl guest devcontainer on arm64 host

Closed this issue ยท 5 comments

VS Code version

1.89.1

Extension version

2.2.2

Biome version

1.7.3

Operating system

  • Windows
  • macOS
  • Linux

Description

When using a musl based linux dev container on a MacOS host (arm64) the wrong biome binary is used.

Steps to reproduce

Init a new project and install biome., then set up dev container.

.devcontainer/devcontainer.json

{
  "name": "devcontainer",
  "build": {
    "dockerfile": "Dockerfile"
  },
  "postCreateCommand": "yarn install",
  "customizations": {
    "vscode": {
      "extensions": [
        "biomejs.biome"
      ]
    }
  }
}

.devcontainer/Dockerfile

FROM alpine:latest

RUN apk update && \
    apk add --no-cache git yarn

Biome finds cli-linux-arm64

Expected behavior

Biome should find cli-linux-arm64-musl

"biome.lspBin": "./node_modules/@biomejs/cli-linux-arm64-musl/biome" makes it work

Does this issue occur when using the CLI directly?

No

Logs

Biome binary found at /workspaces/demo/node_modules/@biomejs/cli-linux-arm64/biome
Copying binary to temporary folder: file:///root/.vscode-server/data/XXXXX/workspaceStorage/XXXXX/biomejs.biome/biome
Executing Biome from: /root/.vscode-server/data/XXXXX/workspaceStorage/XXXXX/biomejs.biome/biome
[Error - 5:27:47 PM] Biome client: couldn't create connection to server.
Error: spawn /root/.vscode-server/data/XXXXX/workspaceStorage/XXXXX/biomejs.biome/biome ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:284:19)
    at onErrorNT (node:internal/child_process:477:16)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)
[cli-stdout] end
[cli-stdout] finish
[cli-stderr] end
[cli-stderr] finish
[cli-stderr] close
[cli] close -2
[cli-stdout] close

When installing biome in the guest, it also installs cli-linux-arm64 although correctly detecting musl base.

info Direct dependencies
โ””โ”€ @biomejs/biome@1.7.3
info All dependencies
โ”œโ”€ @biomejs/biome@1.7.3
โ”œโ”€ @biomejs/cli-linux-arm64-musl@1.7.3
โ””โ”€ @biomejs/cli-linux-arm64@1.7.3

Maybe these need tweaking:

biome-vscode/src/main.ts

Lines 465 to 469 in d9ca2b7

return pnpApi.resolveRequest(
`@biomejs/cli-${process.platform}-${process.arch}/biome${
process.platform === "win32" ? ".exe" : ""
}`,
pkgPath,

biome-vscode/src/main.ts

Lines 488 to 492 in d9ca2b7

const binaryPackage = dirname(
requireFromBiome.resolve(
`@biomejs/cli-${process.platform}-${process.arch}/package.json`,
),
);

process.arch won't return c library I don't think, so perhaps need something similar to what you have here

https://github.com/biomejs/biome/blob/b3da3ae293defe9e3f6f9c1a7f52fbf6450b40c0/packages/%40biomejs/biome/bin/biome#L5-L18

Maybe this

const { execSync } = require('child_process');

function isMusl() {
  try {
    const output = execSync('ldd --version 2>&1', { encoding: 'utf-8' });
    return output.includes('musl');
  } catch (error) {
    return false;
  }
}

Thanks, I'll take a look.

Should be fixed in v2.2.3

Fantastic thanks, seems to work