From 0bc1f09902f44ce12dc062f295795e3e9af1fc2e Mon Sep 17 00:00:00 2001 From: Harper Date: Tue, 1 Jul 2025 15:12:37 -0500 Subject: [PATCH 1/4] Fix libc detection on some musl-based distributions --- .yarn/versions/1f924e2c.yml | 35 ++++++++++++++++++++++ packages/yarnpkg-core/sources/nodeUtils.ts | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 .yarn/versions/1f924e2c.yml diff --git a/.yarn/versions/1f924e2c.yml b/.yarn/versions/1f924e2c.yml new file mode 100644 index 000000000000..7984e0fe3fad --- /dev/null +++ b/.yarn/versions/1f924e2c.yml @@ -0,0 +1,35 @@ +releases: + "@yarnpkg/core": patch + "@yarnpkg/cli": patch + +declined: + - "@yarnpkg/plugin-compat" + - "@yarnpkg/plugin-constraints" + - "@yarnpkg/plugin-dlx" + - "@yarnpkg/plugin-essentials" + - "@yarnpkg/plugin-exec" + - "@yarnpkg/plugin-file" + - "@yarnpkg/plugin-git" + - "@yarnpkg/plugin-github" + - "@yarnpkg/plugin-http" + - "@yarnpkg/plugin-init" + - "@yarnpkg/plugin-interactive-tools" + - "@yarnpkg/plugin-jsr" + - "@yarnpkg/plugin-link" + - "@yarnpkg/plugin-nm" + - "@yarnpkg/plugin-npm" + - "@yarnpkg/plugin-npm-cli" + - "@yarnpkg/plugin-pack" + - "@yarnpkg/plugin-patch" + - "@yarnpkg/plugin-pnp" + - "@yarnpkg/plugin-pnpm" + - "@yarnpkg/plugin-stage" + - "@yarnpkg/plugin-typescript" + - "@yarnpkg/plugin-version" + - "@yarnpkg/plugin-workspace-tools" + - "@yarnpkg/builder" + - "@yarnpkg/doctor" + - "@yarnpkg/extensions" + - "@yarnpkg/nm" + - "@yarnpkg/pnpify" + - "@yarnpkg/sdks" diff --git a/packages/yarnpkg-core/sources/nodeUtils.ts b/packages/yarnpkg-core/sources/nodeUtils.ts index 02d2d438e7a2..ecb8007bad48 100644 --- a/packages/yarnpkg-core/sources/nodeUtils.ts +++ b/packages/yarnpkg-core/sources/nodeUtils.ts @@ -39,7 +39,7 @@ function getLibc() { // Since the getReport can be prohibitely expensive (it also queries DNS which, if misconfigured, can take a long time to timeout), // we first check if the ldd binary is glibc or musl, and only then run the getReport() if we can't determine the libc variant. if (typeof header !== `undefined`) { - if (header && (header.includes(`GLIBC`) || header.includes(`libc`))) + if (header && (header.includes(`GLIBC`) || header.includes(`GNU libc`))) return `glibc`; if (header && header.includes(`musl`)) { return `musl`; From 41ad813d7f85d8abdffa80551e28126bd0f6fb7f Mon Sep 17 00:00:00 2001 From: Harper Date: Tue, 1 Jul 2025 18:39:43 -0500 Subject: [PATCH 2/4] Allow for customized ldd name by searching for license text By default, glib's version of ldd uses the text "GNU libc", but that text is provided by the build system, so it's not guaranteed to be there --- packages/yarnpkg-core/sources/nodeUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/yarnpkg-core/sources/nodeUtils.ts b/packages/yarnpkg-core/sources/nodeUtils.ts index ecb8007bad48..2317714682a5 100644 --- a/packages/yarnpkg-core/sources/nodeUtils.ts +++ b/packages/yarnpkg-core/sources/nodeUtils.ts @@ -39,7 +39,7 @@ function getLibc() { // Since the getReport can be prohibitely expensive (it also queries DNS which, if misconfigured, can take a long time to timeout), // we first check if the ldd binary is glibc or musl, and only then run the getReport() if we can't determine the libc variant. if (typeof header !== `undefined`) { - if (header && (header.includes(`GLIBC`) || header.includes(`GNU libc`))) + if (header && (header.includes(`GLIBC`) || header.includes(`GNU libc`) || header.includes(`GNU C Library`))) return `glibc`; if (header && header.includes(`musl`)) { return `musl`; From 15cf3cb3f57e011757fc92b088aa34465ab2e291 Mon Sep 17 00:00:00 2001 From: Harper Date: Tue, 1 Jul 2025 18:53:42 -0500 Subject: [PATCH 3/4] Fix getLibc() on OSes other than Windows, macOS, and Linux --- packages/yarnpkg-core/sources/nodeUtils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/yarnpkg-core/sources/nodeUtils.ts b/packages/yarnpkg-core/sources/nodeUtils.ts index 2317714682a5..188d1474b42b 100644 --- a/packages/yarnpkg-core/sources/nodeUtils.ts +++ b/packages/yarnpkg-core/sources/nodeUtils.ts @@ -26,9 +26,9 @@ export const openUrl = typeof openUrlBinary !== `undefined` const LDD_PATH = `/usr/bin/ldd` as PortablePath; function getLibc() { - // Darwin and Windows have their own standard libraries, and the getReport() call is costly. - // It also seems that Node randomly crashes with no output under some circumstances when running a getReport() on Windows. - if (process.platform === `darwin` || process.platform === `win32`) + // As of 2025, linux is the only possible process.platform value that does not imply the libc for Node's purposes + // (technically mingw32 exists, but no one seems to care about that, and there have been issues in the past running getReport() on Windows) + if (process.platform !== `linux`) return null; let header: Buffer | undefined; From 51a514ec9b9b118ec4d2aa468347957929d52099 Mon Sep 17 00:00:00 2001 From: Harper Date: Tue, 1 Jul 2025 19:13:40 -0500 Subject: [PATCH 4/4] Clarify comment --- packages/yarnpkg-core/sources/nodeUtils.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/yarnpkg-core/sources/nodeUtils.ts b/packages/yarnpkg-core/sources/nodeUtils.ts index 188d1474b42b..21e3d1467f21 100644 --- a/packages/yarnpkg-core/sources/nodeUtils.ts +++ b/packages/yarnpkg-core/sources/nodeUtils.ts @@ -26,8 +26,9 @@ export const openUrl = typeof openUrlBinary !== `undefined` const LDD_PATH = `/usr/bin/ldd` as PortablePath; function getLibc() { - // As of 2025, linux is the only possible process.platform value that does not imply the libc for Node's purposes - // (technically mingw32 exists, but no one seems to care about that, and there have been issues in the past running getReport() on Windows) + // As of 2025, linux is the only possible process.platform value that does not imply the libc for Node's purposes. + // Technically mingw32 (a way to build and run software using glibc on Windows) exists and even has a node.js port, but no one in + // the broader node.js ecosystem seems to care about it. There have been issues in the past running getReport() on Windows. if (process.platform !== `linux`) return null;